On Sat, 18 Dec 2021 13:07:03 +0000 yesxorno via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> wrote:
> Description: > > When 'exit' is executed in a function called to "in-line" its output to > stdout, the 'exit' acts like return, leaving the function scope, but not > terminating the bash process. It does, in fact, exit the subshell in question. > > Repeat-By: > > Sample script: > > #!/bin/bash > > set -x > > function bar() > { > exit 1 > } > > foo="$(bar)" Here, the use of a command substitution causes a subshell to be created. The command, exit 1, is not run by the shell that the kernel loaded to interpret your script. -- Kerin Millar