diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/exec.c | 7 | ||||
-rw-r--r-- | Test/A04redirect.ztst | 10 |
3 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog index 5d52f6693..8751e93f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-01-20 Peter Stephenson <p.stephenson@samsung.com> + + * users/19751: Src/exec.c, Test/A04redirect.ztst: remove error + on closing file descriptors via number but keep it for those + controlled by variable. + 2015-01-18 Peter Stephenson <p.w.stephenson@ntlworld.com> * 34322: Src/Zle/compctl.c, Src/Zle/compresult.c, Src/exec.c, diff --git a/Src/exec.c b/Src/exec.c index f42fb2b9b..3b0e936b4 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3203,7 +3203,12 @@ execcmd(Estate state, int input, int output, int how, int last1) } if (fn->fd1 < 10) closemn(mfds, fn->fd1, REDIR_CLOSE); - if (!closed && zclose(fn->fd1) < 0) { + /* + * Only report failures to close file descriptors + * if they're under user control as we don't know + * what the previous status of others was. + */ + if (!closed && zclose(fn->fd1) < 0 && fn->varid) { zwarn("failed to close file descriptor %d: %e", fn->fd1, errno); } diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index a39ce46c8..cb6778874 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -152,11 +152,13 @@ >hello >goodbye - ({ exec 3<&- } 2>/dev/null - exec 3<&- - read foo <&-) + (exec {varid}<&0 + exec {varid}<&- + print About to close a second time >&2 + read {varid}<&-) 1:'<&-' redirection -*?\(eval\):*: failed to close file descriptor 3:* +?About to close a second time +*?\(eval\):*: failed to close file descriptor * print foo >&- 0:'>&-' redirection |