I see two possible uses for the SHELL
environment variable:
- It can be used to specify the interactive shell the user wants to use, and/or
- it can be used by processes to execute other commands with, replacing the command in the usual
/bin/sh -c "..."
idiom.
If it were only used for the former, it could be something very weird (e.g. ipython
), if it shall also be used for the latter, it needs to provide a basic form of POSIX compatibility, e.g. understand the -c
parameter and keep the environment intact (which is surprisingly tricky).
The POSIX standard is not very explicit here, it just writes.
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
It seems that make
uses $SHELL -c "..."
, while for example python’s os.system
always uses /bin/sh
.
What isIs the intendedsecond use of theactually common and/or valid, and hence something to worry about if I set $SHELLSHELL
variableto something strange?