variable

Bash BASH_SUBSHELL

Inspect the shell subshell nesting level; top-level script is zero in this fixture.

Formal Syntax & Structure

bash syntaxbash
$BASH_SUBSHELL

Return Value

integer

Inspect the shell subshell nesting level; top-level script is zero in this fixture.

Working Example

Example Snippetbash
printf '%s\n' "$BASH_SUBSHELL"( printf '%s\n' "$BASH_SUBSHELL"; ( printf '%s\n' "$BASH_SUBSHELL" ) )printf '%s\n' "$BASH_SUBSHELL"
Bash Reference