This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Return codes and pipelines


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.

You can force this in your contrived example by adding an exit call.

All of these will print "true:"

(true | true; exit 0) && echo true || echo false
(false | true; exit 0) && echo true || echo false
(true | false; exit 0) && echo true || echo false
(false | false; exit 0) && echo true || echo false


Randall Schulz


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?  (This is not a new
problem, it's been around for at least a year of releases).  It makes
some makefiles not work as expected, specifically, the GCC manual
describes how to perform auto-dependency analysis like:

gcc ... | sed ...

But, if gcc fails, sed will still work, thus make will not consider it a
failure and will continue.

I know there are many ways to avoid this specific problem, already
implemented one.  Just wanted to let you guys know.


-Rolf Campbell






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]