diff --git a/lib/console-text-color-themes.sh b/lib/console-text-color-themes.sh index c7b3d287..4f9b4fb9 100755 --- a/lib/console-text-color-themes.sh +++ b/lib/console-text-color-themes.sh @@ -26,10 +26,6 @@ if command -v greadlink >/dev/null; then _ctct_READLINK_CMD=greadlink fi -# NOTE: DO NOT declare var _ctct_PROG as readonly in ONE line! -_ctct_PROG="$(basename -- "$($_ctct_READLINK_CMD -f -- "${BASH_SOURCE[0]}")")" -[ "$_ctct_PROG" == 'console-text-color-themes.sh' ] && readonly _ctct_is_direct_run=true - readonly _ctct_ec=$'\033' # escape char readonly _ctct_eend=$'\033[0m' # escape end @@ -55,9 +51,10 @@ colorEchoWithoutNewLine() { fi } -# if not directly run this script(use as lib), just export 2 helper functions, -# and do NOT print anything. -[ "$_ctct_is_direct_run" == true ] && { +# if not directly run this script(use as lib), just export 2 helper functions, and do NOT print anything. +# +# if directly run this script, the length of array BASH_SOURCE is 1. +if ((${#BASH_SOURCE[@]} == 1)); then for style in 0 1 2 3 4 5 6 7; do for fg in 30 31 32 33 34 35 36 37; do for bg in 40 41 42 43 44 45 46 47; do @@ -97,4 +94,4 @@ colorEchoWithoutNewLine() { echo 'Output of above code:' echo -n ' ' colorEcho '1;36;41' 'Sample Text' -} +fi