From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18216 invoked from network); 25 Oct 2002 11:16:42 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 25 Oct 2002 11:16:42 -0000 Received: (qmail 29352 invoked by alias); 25 Oct 2002 11:16:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17855 Received: (qmail 29328 invoked from network); 25 Oct 2002 11:16:21 -0000 From: Borzenkov Andrey To: "'Matthias Scheler'" , zsh-workers@sunsite.dk Subject: RE: I/O redirection problem in "zsh" Date: Fri, 25 Oct 2002 15:16:13 +0400 Message-ID: <6134254DE87BD411908B00A0C99B044F03A0B4B6@MOWD019A> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 In-Reply-To: <20021025104047.GA27855@colwyn.zhadum.de> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 > > 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