[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $? in the right side of a pipe
From: |
Stephane CHAZELAS |
Subject: |
Re: $? in the right side of a pipe |
Date: |
Mon, 27 Dec 2010 13:15:51 +0000 (UTC) |
User-agent: |
slrn/pre1.0.0-18 (Linux) |
2010-12-27, 13:14(+01), <dnade.ext@orange-ftgroup.com>:
> Hello
>
> More information on that topic :
>
> false ; false | echo $? stills prints 0.
> false ; (false) | echo $? prints 1
>
> So.. ? $? in the right side of a pipe is randomly the exit
> status of the left side depending of the way you write it ?
> Doesn’t sound sane.
That's not the exit status of the left side. It couldn't be as
both sides of the pipe are started at the same time and run
concurrently.
> Doesn’t that break POSIX anyway ?
I suppose it does. I can't see any reason why the above
shouldn't print 1 in any case.
> I think it should be fixed.
Me too.
Note that $PIPESTATUS doesn't seem to be affected by that bug.
$ bash -c '(exit 2) | (exit 3) ; false | echo $?, "${PIPESTATUS[@]}"'
0, 2 3
--
Stephane