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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2024-11-10 at 02:38 -0500, Lawrence Velázquez wrote:
> 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.

My wording was bad,... with "ignore" at that point (in the non --posix
example) I mean what you said, i.e. that it clears the flag again as
also described in its manpage.

My examples were bad, too, as I forgot to add the "ignoring" context,
as you already did with your second example.

But even without explicitly re-setting -e inside the command
substitution, though in --posix mode:

bash --posix
bash-5.2$ set -e
bash-5.2$  echo "$(echo $-; false; echo b)" || :
ehimBHs
b
$

So it keeps -e (in --posix) AND ignores it (because of the || : ), as
IMO mandated by POSIX.


Cheers,
Chris






[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux