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    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to