Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <5.2.0.9.2.20030112211313.0276dec0@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com Date: Sun, 12 Jan 2003 21:22:55 -0800 To: cygwin AT cygwin DOT com From: Randall R Schulz Subject: Re: Return codes and pipelines In-Reply-To: <20030113045329.GA15590@butch.jgcomp.com> References: <5 DOT 2 DOT 0 DOT 9 DOT 2 DOT 20030112141731 DOT 01df7bc8 AT pop3 DOT cris DOT com> <83040F98B407E6428FEC18AC720F5D73015BA93F AT exchange DOT tropicnetworks DOT com> <5 DOT 2 DOT 0 DOT 9 DOT 2 DOT 20030112141731 DOT 01df7bc8 AT pop3 DOT cris DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Jon, Well, Cygwin does not include Bourne shell, it has BASH, ash and zsh, but it does appear that the status returned by a parenthesized pipeline under BASH is that of the last command in that pipeline. Strictly speaking, that's not at odds with the first part of what I said, which is that the parent - child process relationship between processes in a pipeline is not specified. So this leaves one puzzle: Why is it that Rolf is getting different results for this command between Linux and Cygwin? (false | true) && echo true || echo false Rolf, which shells are you using on Linux and Cygwin? Randall Schulz At 20:53 2003-01-12, Jon LaBadie wrote: >On Sun, Jan 12, 2003 at 02:21:45PM -0800, Randall R Schulz wrote: > > Rolf, > > > > One posting is enough, really. > > > > There is no guaranteed or specified parent child relationship between the > > processes in a pipeline. This means that you cannot predict which > process's > > status will be the one returned as that of the pipeline as a whole. > > > > At 14:09 2003-01-12, Rolf Campbell wrote: > > >/home/rcampbell> (true | true) && echo true || echo false > > >true > > >/home/rcampbell> (true | false) && echo true || echo false > > >false > > >/home/rcampbell> (false | true) && echo true || echo false > > >true > > >/home/rcampbell> (false | false) && echo true || echo false > > >false > > > > > >The third test above yields different results when run on Linux. I'm > > >wondering if this was the desired result or not? > > >There is (or had been last I looked at the source) a defined relationship >in the Bourne and Korn shells at least. > >The parent forks the last command in a pipeline which then becomes the >parent of the other commands in the pipeline. Thus the original parent >only sees the last command's exit status. > >This scheme was done to implement the following behavior back around >System V.2 in the great Bourne shell "rewrite in C". > > >From the current Solaris man page for Bourne Shell: > > ... . Each command is run as a separate process; the > shell waits for the last command to terminate. The exit > status of a pipeline is the exit status of the last command > in the pipeline. > >The addition of the pipefail option to recent ksh93 versions suggests >this relation-ship scheme has been altered in those shells. But I >do not think it appropriate to generically say there is no defined >relationship as if it applies to every shell out there. > >-- >Jon H. LaBadie jcyg AT jgcomp DOT com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/