Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: I/O redirection problem in "zsh"
- X-seq: zsh-workers 17855
- From: Borzenkov Andrey <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: "'Matthias Scheler'" <tron@xxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: RE: I/O redirection problem in "zsh"
- Date: Fri, 25 Oct 2002 15:16:13 +0400
- Importance: Normal
- In-reply-to: <20021025104047.GA27855@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
>
> Hello,
>
> the I/O redirection in the following command doesn't work properly in
> "zsh":
>
> grep localhost /etc/hosts fasel 2>&1 >/dev/null | cat -b
>
> tron@colwyn:~>grep localhost /etc/hosts fasel 2>&1 >/dev/null | cat -b
> 1 grep: fasel: No such file or directory
> 2 /etc/hosts:::1 localhost
> 3 /etc/hosts:127.0.0.1 localhost
> tron@colwyn:~>sh
> $ grep localhost /etc/hosts fasel 2>&1 >/dev/null | cat -b
> 1 grep: fasel: No such file or directory
> $ bash
> bash-2.05$ grep localhost /etc/hosts fasel 2>&1 >/dev/null | cat -b
> 1 grep: fasel: No such file or directory
> bash-2.05$ ksh
> $ grep localhost /etc/hosts fasel 2>&1 >/dev/null | cat -b
> 1 grep: fasel: No such file or directory
>
> I can reproduce this problem with ZSH 3.0.8 under Solaris and ZSH
4.0.6
> under NetBSD.
>
This ambiguous. Both > and | mean redirection of stdout. Now, Zsh first
does redirections and then applies pipeline (which effectively reopens
stdout) and other shells first apply pipeline and then (inside of simple
command) do redirections. The following from SUS makes me believe Zsh
is more correct:
"The standard output of command1 shall be connected to the standard
input of command2. The standard input, standard output, or both of a
command shall be considered to be assigned by the pipeline before any
redirection specified by redirection operators that are part of the
command (see Redirection )."
What other shells effectively do is to pipeline stderr not stdout.
Still I do not fully understand this sentence so I am not sure if my
interpretation is correct.
-andrey
Messages sorted by:
Reverse Date,
Date,
Thread,
Author