Re: set -e not ignored in AND-OR list
Christoph Anton Mitterer <[email protected]> Tue, 05 Nov 2024 03:25:08 +0100
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
Think I found another case:
$ dash; echo shell left
$ set -e; foo() { echo a >&2; false; echo b >&2; }
$ echo "$(foo)"
a
=> expected, no reason to ignore -e, no exit either, as part of word
expansion (POSIX’ point (1))
$ echo "$(foo)" | true
a
=> expected, no reason to ignore -e, no exit either, as pipefail not in
effect
$ echo "$(foo)" || true
a
$ echo "$(foo)" && true
a
=> the above two are probably the same bug from before, I just mention
them again, as it does happen in a word expansion, so a future check
for this might want t test both cases
(bash in both prints a and b)
Here's the new one:
$ ! echo "$(foo)" | true
a
$
=> before,
$ ! foo | true
worked properly in dash, i.e. the -e WAS ignored
but here it is NOT ignored, which I think it should be
And in fact, bash for the same gives:
$ bash; echo shell left
$ shopt -s inherit_errexit
$ set -e; foo() { echo a >&2; false; echo b >&2; }
$ ! echo "$(foo)" | true
a
b
$
Cheers,
Chris.