On Mon, Aug 07, 2023 at 01:56:21PM +0000, Kamil Cukrowski Priv wrote: > Hi, when BASH_SUBSHELL is part of a pipeline with just a simple command it > does not increment. Consider the following: > # docker run -ti --rm bash bash -c 'echo $BASHPID $BASH_SUBSHELL; echo | > echo $BASHPID $BASH_SUBSHELL'
There are no subshells in that, except for the pipeline. Invoking "bash -c" does not create a subshell. It creates a new shell. You might want to look at the SHLVL variable. Or redesign whatever it is you're doing which relies on counting levels of shells and subshells.