difference_between_shell_and_0
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
difference_between_shell_and_0 [2023/01/03 21:45] – created raju | difference_between_shell_and_0 [2023/01/03 22:14] (current) – raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | blah | + | ==== Difference between \$SHELL and \$0 ==== |
- | foo | + | Q. What is the difference between \$SHELL and \$0? |
+ | |||
+ | A. | ||
+ | * \$SHELL is just an environment variable that gives the absolute path to the user's default login shell. | ||
+ | * \$0 gives the absolute path of the current shell. | ||
+ | |||
+ | For example, if you launch a new shell from the current shell, \$SHELL will not | ||
+ | change but \$0 will. | ||
+ | |||
+ | < | ||
+ | % echo "\$0 is $0; \$SHELL is $SHELL" | ||
+ | $0 is / | ||
+ | |||
+ | % dash | ||
+ | $ echo "\$0 is $0; \$SHELL is $SHELL" | ||
+ | $0 is dash; $SHELL is / | ||
+ | |||
+ | $ bash | ||
+ | $ echo "\$0 is $0; \$SHELL is $SHELL" | ||
+ | $0 is bash; $SHELL is / | ||
+ | |||
+ | $ sh | ||
+ | $ echo "\$0 is $0; \$SHELL is $SHELL" | ||
+ | $0 is sh; $SHELL is / | ||
+ | </ | ||
+ | |||
+ | A running shell does not control \$SHELL. It is set by the ' | ||
+ | is exported to the child processes. The ' | ||
+ | to set the \$SHELL variable. | ||
+ | |||
+ | See also: 'man 1 login' | ||
+ | |||
+ | Tested this with | ||
+ | |||
+ | < | ||
+ | % dpkg -l zsh dash bash sh | cut -c 1-72 | ||
+ | dpkg-query: no packages found matching sh | ||
+ | Desired=Unknown/ | ||
+ | | Status=Not/ | ||
+ | |/ Err? | ||
+ | ||/ Name | ||
+ | +++-==============-============-============-=========================== | ||
+ | ii bash | ||
+ | ii dash | ||
+ | ii zsh 5.0.7-5 | ||
+ | </ | ||
+ | |||
+ | {{tag> | ||
+ | |||
+ | ==== related pages ==== | ||
+ | * [[Change the default shell]] | ||
+ | * [[Which shell am I using | Which shell am I using?]] |
difference_between_shell_and_0.1672782309.txt.gz · Last modified: 2023/01/03 21:45 by raju