* overeager multios
@ 2003-02-10 4:26 Andrew Pimlott
0 siblings, 0 replies; only message in thread
From: Andrew Pimlott @ 2003-02-10 4:26 UTC (permalink / raw)
To: zsh-workers
I just spent several minutes trying to understand a behavior that
turned out to be caused by unexpected triggering of multios. A
simple example is
echo hello 3>&1 >&2 | cat
which prints "hello" twice, instead of once as in bash. (In
reality, "echo hello" would be a program that writes to both fds 1
and 3.) I think multios is overeager here, as this is a standard
shell idiom, and the only way I know of to achieve this effect.
A fix would be to ignore (for multios purposes) previous opens when
a fd is duped. the shell would process the above as follows.
1. fd 1 will be opened to the pipe. Push that open onto the
multios stack for fd 1.
2. fd 1 will be duped to fd 3. Clear the multios stack.
3. fd 2 will be duped to fd 1. Push that open onto the multios
stack.
4 fd 1 has only one entry in its multios stack, so don't trigger
multios.
This will ensure that multios only triggers on a command line that
has no useful meaning in sh.
I know I can turn off multios, but I think we can have the best of
both with the above algorithm.
I am using the zsh 4.0.6-13 package on Debian GNU/Linux.
Andrew
PS. Please Cc: me as I am not subscribed.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-02-10 4:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-10 4:26 overeager multios Andrew Pimlott
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).