[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BASH_SUBSHELL is not incrementing when part of a pipeline
From: |
Greg Wooledge |
Subject: |
Re: BASH_SUBSHELL is not incrementing when part of a pipeline |
Date: |
Mon, 7 Aug 2023 10:09:59 -0400 |
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.