zsh-workers
 help / color / mirror / code / Atom feed
* zsh silently abandons compound command on trying to write to a closed file descriptor
@ 2016-10-27 17:21 Martijn Dekker
  2016-10-27 20:01 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Martijn Dekker @ 2016-10-27 17:21 UTC (permalink / raw)
  To: Zsh hackers list

zsh misbehaves if a redirection produces an error due to writing to a
closed file descriptor. For instance,

    echo hi >&- || echo oops

doesn't output "oops" as expected. But the shell is not exited, only the
current compound command is apparently abandoned -- silently, without an
error message or even a non-zero exit status.

Test script:

	echo hi >&- || ! echo oops
	echo $?

'zsh test.sh' and 'zsh -o posixbuiltins test.sh' both output 0 (and
nothing else). Expected output is an error message followed by "oops"
followed by 1.

Relevant POSIX text is at:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_01

Thanks,

- M.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: zsh silently abandons compound command on trying to write to a closed file descriptor
  2016-10-27 17:21 zsh silently abandons compound command on trying to write to a closed file descriptor Martijn Dekker
@ 2016-10-27 20:01 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2016-10-27 20:01 UTC (permalink / raw)
  To: Zsh hackers list

On Oct 27,  6:21pm, Martijn Dekker wrote:
}
} zsh misbehaves if a redirection produces an error due to writing to a
} closed file descriptor. For instance,
} 
}     echo hi >&- || echo oops
} 
} doesn't output "oops" as expected.

This is exactly the same thing we discussed back in Feburary on the
thread you started with workers/38044, and which was also discussed
in January in workers/37505 and 37506, and which originally came
from workers/16556 with justification in workers/16559.

Somewhere in the middle of that it was noted that Bash no longer has
the behavior referenced in 16559, but there was never an assertion
that we ought to change zsh as well.  The February thread just stops.

It's not "abandoning" the compound command, nor is it an issue with
the file descriptor; it's specific to the print builtin and its
synonyms, which includes echo.

torch% echo hi >&- && echo not abandoned
not abandoned
torch% /bin/echo hi >&-
/bin/echo: write error: Bad file descriptor
torch% echo $?
1
torch% /bin/echo hi >&- || echo oops
/bin/echo: write error: Bad file descriptor
oops


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-27 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 17:21 zsh silently abandons compound command on trying to write to a closed file descriptor Martijn Dekker
2016-10-27 20:01 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).