Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/build not work on linux because builtin cd will output the folder name. #244

Open
zw963 opened this issue Oct 6, 2022 · 1 comment

Comments

@zw963
Copy link

zw963 commented Oct 6, 2022

 ╰─ $ 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

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.

@zw963
Copy link
Author

zw963 commented Oct 7, 2022

BTW, this issue only happen when set $CDPATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant