Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: multios doesn't work with 2>&1
- X-seq: zsh-users 18061
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: multios doesn't work with 2>&1
- Date: Sun, 27 Oct 2013 10:01:37 -0700
- In-reply-to: <20131027145917.GA5509@localhost.localdomain>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20131027145917.GA5509@localhost.localdomain>
On Oct 27, 10:59pm, Han Pingtian wrote:
}
} According to the zsh guide's "2.5.8 `Go faster' options for power
} users", page 44:
}
} % echo foo 2>&1 >/dev/null | sed 's/foo/bar/'
}
} should output "bar" if multios has been set. But it outputs nothing
Hmm, looks like this has been broken for a LONG time.
If I back out workers/20666 (Jan 2005), then this example works again.
Note that
% print -u2 foo 2>&1 >/dev/null | sed 's/foo/bar/'
does print "bar", so the problem is that the original fd 1 is directed
to /dev/null while the multio fd created by 2>&1 is is directed to the
pipe. You can see the reasoning for this in the "references" thread
going back from http://www.zsh.org/mla/workers/2005/msg00026.html
The workaround is to either explicitly add the original stdout to the
multio:
% echo foo 2>&1 >&1 >/dev/null | sed 's/foo/bar/'
Or to make sure the multio isn't created until the pipe is seen:
% { echo foo 2>&1 } >/dev/null | sed 's/foo/bar/'
If there's a way to fix the original complaint (that >&- doesn't really
close the descriptor when a multio is involved, so unnecessary multios
result) without the above example remaining broken, I may need some help
to find it.
Otherwise we have to decide whether to revert to the pre-2005 behavior,
or document around it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author