I am accidentally caught in a desire to reveal the subshell number (BASH_SUBSHELL) from within the script itself, but i get subshell 0
Here is the script's line
echo "Operated from subshell: $BASH_SUBSHELL
Part of the shell's output in terminal
- echo 'Operated from subshell: 0' Operated from subshell: 0
Question Is it possible to reveal the subshell a script is operating from within the script itself?
ps -f
the PID of the shell (i.e bash ) was exactly the same as the PPID (Parent's PID) ofbash script.sh
. Doesn't this prove that a running shell script runs in it's own subshell? – Jim-chriss Charles Apr 24 '19 at 15:54filename _arguments_
is equivalent to executingbash filename _arguments_
. iffilename
is an executable shell script. This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to interpret the script,... – Jim-chriss Charles Apr 25 '19 at 16:27