Skip to main content
edited tags
Link
muru
  • 77.9k
  • 16
  • 212
  • 317
Make the question clearer.
Source Link
Joachim Breitner
  • 1.4k
  • 4
  • 17
  • 25

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?

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 is the intended use of the $SHELL variable?

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.

Is the second use actually common and/or valid, and hence something to worry about if I set SHELL to something strange?

Fixed bad edit
Source Link
terdon
  • 252.2k
  • 69
  • 480
  • 718

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.

Could someone shed a light aboutWhat is the two approachesintended use of the $SHELL variable?

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.

Could someone shed a light about the two approaches?

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 is the intended use of the $SHELL variable?

deleted 19 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237
Loading
Source Link
Joachim Breitner
  • 1.4k
  • 4
  • 17
  • 25
Loading