[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PIPESTATUS inconsistent behavior in 3.0
From: |
Chet Ramey |
Subject: |
Re: PIPESTATUS inconsistent behavior in 3.0 |
Date: |
Thu, 11 Aug 2005 11:07:07 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Macintosh/20050716) |
Frank Wang wrote:
> Machine Type: i386-redhat-linux-gnu
>
> Bash Version: 3.0
> Patch Level: 16
> Release Status: release
>
> Description:
> Here is what I got from my fc4 box.
> [frank@twinhead ~]$ echo $BASH_VERSION
> 3.00.16(1)-release
> [frank@twinhead ~]$ ls | bogus_command | wc
> 0 0 0
> [frank@twinhead ~]$ echo ${PIPESTATUS[@]}
> 141 127 0
This is not a bug. The exit status of `ls' can vary, depending on
whether or not it's killed by SIGPIPE or manages to write all of its
output before exiting. When it's killed by SIGPIPE -- writing to a
pipe with no reader -- the exit status is 141. When it completes
writing its output, the exit status will be 0. The same goes for
`tr'.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/