Skip to main content
added 3 characters in body
Source Link
Stéphane Chazelas
  • 584.4k
  • 96
  • 1.1k
  • 1.7k

In the case of bash, that depends on whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the $BASHOPTS variable.

It comes handy especially for the xtrace option for debugging when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace (provided nothing does a set +x in those scripts). If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command

In the case of bash, that depends whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the $BASHOPTS variable.

It comes handy especially for the xtrace option for debugging when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace (provided nothing does a set +x in those scripts). If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command

In the case of bash, that depends on whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the $BASHOPTS variable.

It comes handy especially for the xtrace option for debugging when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace (provided nothing does a set +x in those scripts). If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command
added 68 characters in body
Source Link
Stéphane Chazelas
  • 584.4k
  • 96
  • 1.1k
  • 1.7k

In the case of bash, that depends whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the BASHOPTS$BASHOPTS optionvariable.

It comes handy especially for the xtrace option for debugging when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace (provided nothing does a set +x in those scripts). If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command

In the case of bash, that depends whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the BASHOPTS option.

It comes handy especially for the xtrace option when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace. If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command

In the case of bash, that depends whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the $BASHOPTS variable.

It comes handy especially for the xtrace option for debugging when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace (provided nothing does a set +x in those scripts). If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command
Source Link
Stéphane Chazelas
  • 584.4k
  • 96
  • 1.1k
  • 1.7k

In the case of bash, that depends whether $SHELLOPTS is in the environment or not.

bash-4.4$ export SHELLOPTS
bash-4.4$ set -x
bash-4.4$ bash -c 'echo x'
+ bash -c 'echo x'
+ echo x
x

See how the bash -c 'echo x' inherited the xtrace option. For the options set by shopt, it's the same but with the BASHOPTS option.

It comes handy especially for the xtrace option when you want to run a bash script (or any command running a bash script) and all other bash script it may invoke, recursively with xtrace. If your sh is bash, that will also affect them, so also the system("command line") made in other languages:

env SHELLOPTS=xtrace some-command