Re: set -e not ignored in AND-OR list

Lawrence Velázquez <[email protected]> Sun, 10 Nov 2024 02:38:58 -0500
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
On Sun, Nov 10, 2024, at 1:08 AM, Christoph Anton Mitterer wrote:
> I know that bash ignores set -e per default in the standard (which I
> think is however NOT POSIX compliant either), e.g.
>
> bash without --posix:
> $ set -e 
> $ echo "$(echo a; false; echo b)"
> a
> b
> $

Bash does NOT ignore "set -e" here; it just sets "set +e" in the
command substitution subshell.  You can see this by reenabling
"set -e" inside:

	$ ./bash -ec 'echo "$(set -e; echo a; false; echo b)"'
	a

Compare with a context in which it actually does ignore "set -e":

	$ ./bash -ec '! echo "$(set -e; echo a; false; echo b)"'
	a
	b

-- 
vq