Open zw963 opened 1 year ago
╰─ $ builtin cd bin /home/zw963/bin ╭─ 02:05 zw963 ⮀ ~/bin ⮀ ➦ 0 ╰─ $ cd .. ╭─ 02:06 zw963 ⮀ ~ ⮀ ➦ 0 ╰─ $ \cd bin /home/zw963/bin
So, this the following output will be:
here=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
The here variable would output 2 line string, instead only 1 line.
╰─ $ bin/1.sh +++ dirname bin/1.sh ++ cd bin ++ pwd + here='/home/zw963/bin /home/zw963/bin'
here is /home/zw963/bin /home/zw963/bin
/home/zw963/bin /home/zw963/bin
so, it should be fix with:
here=$(cd "$(dirname "$BASH_SOURCE")" >/dev/null; pwd)
print the cd folder name probably is a shell config issue, but, anyway, new config more robust.
BTW, this issue only happen when set $CDPATH
So, this the following output will be:
The here variable would output 2 line string, instead only 1 line.
here is
/home/zw963/bin /home/zw963/bin
so, it should be fix with:
print the cd folder name probably is a shell config issue, but, anyway, new config more robust.