Skip to content

Commit 4923278

Browse files
committed
! readlink "${BASH_SOURCE[0]}" instead of $0
readlink "${BASH_SOURCE[0]}" will success even run by `bash -x foo`, foo script is found from $PATH
1 parent 6696472 commit 4923278

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

bin/uq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
set -eEuo pipefail
1414

1515
PROG="$(basename "$0")"
16-
PROG_PATH="$(readlink -f "$0")"
16+
PROG_PATH="$(readlink -f "${BASH_SOURCE[0]}")"
1717
PROG_DIR="$(dirname "$PROG_PATH")"
1818

1919
################################################################################

bin/xpf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
# @author Jerry Lee (oldratlee at gmail dot com)
1111
set -eEuo pipefail
1212

13+
# BASE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
1314
BASE="$(dirname "$0")"
1415
source "$BASE/xpl" "$@"

lib/console-text-color-themes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-console-text-color-themessh
66
# @author Jerry Lee (oldratlee at gmail dot com)
77

8-
readonly _ctct_PROG="$(basename "$(readlink -f "$0")")"
8+
readonly _ctct_PROG="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99
[ "$_ctct_PROG" == 'console-text-color-themes.sh' ] && readonly _ctct_is_direct_run=true
1010

1111
readonly _ctct_ec=$'\033' # escape char

0 commit comments

Comments
 (0)