I would like to know the exact difference between $0 and $SHELL. I know that these two are used to know the shell info. It would be great if some one explain with examples.
What does it indicate if both show different values as below ?
# echo $0
ksh
# echo $SHELL
/sbin/sh
#
SHELL
is just an environment variable, while $0
is the path of the currently running program. The user should set SHELL
to the value of the preferred shell, similar to the way the user sets PAGER
and EDITOR
. Any program that needs to spawn a shell should check the value of SHELL
to determine which shell to invoke. SHELL
is not the path of the shell you get when you login. It will not change when a new shell is run any more than PAGER
will change if it is set to less
but the user invokes more
, or if EDITOR
is set to vi
and the user runs emacs
. For instance:
$ echo $0 $SHELL
bash /bin/bash
$ exec csh
% echo $0 $SHELL
csh /bin/bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With