On 4/13/22 8:58 AM, Frank Heckenbach wrote:
Bash Version: 5.1
Patch Level: 16
Release Status: release
Description:
This script writes "foo" to bar rather than stdout as I'd expect.
That's not unreasonable, but it's not how it works.
It's triggered by the "if" statement (which doesn't even cause
running in a subshell, so it's not that).
The entire `if' statement executes with its stdout redirected. That means
the `false' that causes the shell to exit immediately has its stdout
redirected, which the exit trap inherits.
Most shells behave like bash does here; dash is a notable exception.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/