[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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: |
Mon, 21 Aug 2023 16:00:55 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 |
On 8/20/23 12:15 AM, Grisha Levit wrote:
exec {foo}>/tmp/foo
exec "${foo}"<&-
Looks like bash doesn't undo redirections if the exec fails -- so the shell
terminates because the redirection closed stdin.
I agree it would probably make sense to undo them if the exec fails and the
shell is not going to exit.
The latest draft of the upcoming POSIX revision says:
"If the exec command fails and the shell does not exit, any redirections
associated with the exec command that were successfully made shall take
effect in the current shell execution environment."
--
``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/
- using exec to close a fd in a var crashes bash, jleivent, 2023/08/19
- Re: using exec to close a fd in a var crashes bash, Greg Wooledge, 2023/08/19
- Re: using exec to close a fd in a var crashes bash, Grisha Levit, 2023/08/20
- Re: using exec to close a fd in a var crashes bash, Chet Ramey, 2023/08/21
- Re: using exec to close a fd in a var crashes bash, Dale R. Worley, 2023/08/22
- Re: using exec to close a fd in a var crashes bash, Chet Ramey, 2023/08/22
- Re: using exec to close a fd in a var crashes bash, Greg Wooledge, 2023/08/22
- Re: using exec to close a fd in a var crashes bash, Martin D Kealey, 2023/08/22
- Re: using exec to close a fd in a var crashes bash, Greg Wooledge, 2023/08/22
- Re: using exec to close a fd in a var crashes bash, Martin D Kealey, 2023/08/23
- Re: using exec to close a fd in a var crashes bash, Zachary Santer, 2023/08/23
- Re: using exec to close a fd in a var crashes bash, Greg Wooledge, 2023/08/23