Timeline for Are all bash scripts compatible with `zsh`?
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 2, 2020 at 17:42 | comment | added | Gilles 'SO- stop being evil' | @rrr No. ./test.sh runs test.sh as a separate program. Sourcing would be . ./test.sh, so run the content of the file more or less like a function call inside the same process. | |
| Dec 2, 2020 at 17:14 | comment | added | rrr | When you source a script with a #!/bin/bash from zsh, zsh calls /bin/bash and passes the script file to it. So @BallpointBen 's comment that the shebang is ignored is misleading. Example: make a test.sh script with #!/bin/bash and sleep 10 in it. Then run it as ./test.sh from zsh. Then type ps aux | grep bash, which shows all the running processes that have bash in their names, and you will see /bin/bash ./test.sh. | |
| Oct 4, 2020 at 5:14 | comment | added | vampiire | thank you @BallpointBen i went down a rabbit hole that ended at your comment. turns out dicts / associative array syntax is vastly different between bash and zsh and i was going nuts trying to figure out what was happening when i sourced some funcs from a bash script | |
| Aug 29, 2018 at 15:03 | comment | added | BallpointBen | The shell you use is irrelevant if you run your scripts as ./my_script.sh. source my_script.sh and . my_script.sh will run it is as the current shell, ignoring any shebang. | |
| Aug 8, 2018 at 20:50 | history | edited | Gilles 'SO- stop being evil' | CC BY-SA 4.0 | add a note about people who write snippets to source |
| May 8, 2012 at 23:04 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |