Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
overeager multios
- X-seq: zsh-workers 18214
- From: Andrew Pimlott <andrew@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: overeager multios
- Date: Sun, 9 Feb 2003 23:26:44 -0500
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author