The bash manual says
BASH_SUBSHELL Incremented by one within each subshell or subshell environment when the shell begins executing in that environment. The initial value is 0.
SHLVL Incremented by one each time a new instance of Bash is started. This is intended to be a count of how deeply your Bash shells are nested.
What are the differences between the two builtin variables?
Specifically what differences are between "subshell or subshell environment" and "Bash shells"?
In the following example, why does the value of
BASH_SUBSHELL not change, while the value of
$ echo $BASH_SUBSHELL 0 $ echo $SHLVL 1 $ bash $ echo $BASH_SUBSHELL 0 $ echo $SHLVL 2