When running a shell script, the script might need to know whether itis running zsh, bash, etc.
Even if your terminal is zsh, when you run ./foo.sh the script might be running bash by default.
There are several ways to
try to determine which shell the script is running, but across different operating systems (Windows, Apple, unix) different things happen.
This is a set of scripts that print out various indicators. I've also included the same script with
the directives #!/usr/bin/zsh and #!/usr/bin/bash at the top so you can try them too.
-
to download a zip file with several scripts
- unzip and cd into the whichShell/scripts/ directory
- chmod u+x the scripts
- run them with different sh languages:
./whichShell.sh
bash ./whichShell.sh
zsh ./whichShell.sh
|
- try running with different directives (files with #!/usr/bin/zh or #!/usr/bin/bash):
./whichShellBash.sh
./whichShellZsh.sh
bash ./whichShellZsh.sh
zsh ./whichShellBash.sh
|