Beware however that this refers only to parts which are obviously written by me and do not have any other information about licencing. Quoted text, pictures and other content created by others is copyrighted by the corresponding authors. If you are in doubt, ask before republishing any content.
Short Tip: determine current shell
July 28, 2007 — liquidat
To figure out the current shell you’re using, like bash, zsh or sh, just call ps -p $$:
ps -p $$ | tail -1 | awk '{print $NF}'
Pretty helpful if you’re playing with different shells at the same time.
The variable $SHELL contains the path to the current shell and $0 only represents the first argument given to a program (aka the name of the actual programm). To understand what I mean do the following:
cd /home/liquidat
../../tmp/../bin/bash
echo $0
$SHELL is the default shell. My question is how to determine the type of the shell in the script if the script is executable and invoked directly by the console (e.g., ./shell.sh).
August 5, 2007 at 19:25
The variable $SHELL contains the path to the current shell and $0 only represents the first argument given to a program (aka the name of the actual programm). To understand what I mean do the following:
cd /home/liquidat
../../tmp/../bin/bash
echo $0
August 6, 2007 at 8:30
Ah, thanks, didn’t knew that, I never stop learning
July 13, 2008 at 5:05
$SHELL is just an enironment variable, it’s not always correct
fess@McBean-1005% echo $SHELL
/bin/zsh
fess@McBean-1006% /bin/bash
McBean:~ fess$ echo $SHELL
/bin/zsh
so where you think it would be bash it’s still zsh.
July 25, 2008 at 3:52
$SHELL is the default shell. My question is how to determine the type of the shell in the script if the script is executable and invoked directly by the console (e.g., ./shell.sh).