You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expansion of $0 differs from one in bash and zsh in script, even when shell explicitly set with shebang. My test show that this behaviour changed in 3.5.0 resulting in broken bash scripts.
Fish version:
fish --version
fish, version 3.5.1
System version:
$ uname -a
Darwin XXXXX-MacBook-Pro.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64
$ echo $TERM
xterm-256color
I've tried sh -c 'env HOME=$(mktemp -d) fish' and got same results
I know that compatability with other shells not guaranteed, but it would be nice to have at least clear statement about it in changelog.
Though, it's not crystal clear to me, why behaviour differs even with shebang.
The text was updated successfully, but these errors were encountered:
t this behaviour changed in 3.5.0 resulting in broken bash scripts.
If your bash script is "broken" by this, it is already broken. $0 can always be absolute. Call $PWD/expansion.sh in bash, and it will be absolute. Call it as e.g. /path/to/script/expansion.sh from elsewhere, and it'll be absolute.
$0 is one of those brilliant unix features that appear to be nice and simple until you figure out they aren't. $0 can be any relative or absolute path to your script - unless you tell the shell to use another value:
bash -c '. ./expansion.sh' /bin/grep
Now your script thinks it is /bin/grep in bash and dash, but './expansion.sh' in zsh.
I'd probably lean towards changing this back because it wasn't supposed to be changed, but your use of $0 isn't actually any good, and it's not like we pass any arbitrary value here. It's a perfectly cromulent path to the script.
Expansion of $0 differs from one in bash and zsh in script, even when shell explicitly set with shebang. My test show that this behaviour changed in 3.5.0 resulting in broken bash scripts.
Fish version:
System version:
I've tried
sh -c 'env HOME=$(mktemp -d) fish'
and got same resultsSteps to reproduce:
I know that compatability with other shells not guaranteed, but it would be nice to have at least clear statement about it in changelog.
Though, it's not crystal clear to me, why behaviour differs even with shebang.
The text was updated successfully, but these errors were encountered: