Re: using exec to close a fd in a var crashes bash
From:
Chet Ramey
Subject:
Re: using exec to close a fd in a var crashes bash
Date:
Fri, 25 Aug 2023 16:12:58 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0
On 8/23/23 9:50 AM, Zachary Santer wrote:
In the Bash man page:
varredir_close
If set, the shell automatically closes file descriptors assigned
using the {varname} redirection syntax (see REDIRECTION above) instead of
leaving them open when the command completes.
I feel like the man page would benefit from that caveat about exec. I felt
the need to test that bit myself. "Surely not."
That addresses the aspect of the behavior that people complain about. If
you use `exec', you want the redirections to persist -- that's the purpose
of using redirections with exec.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/