Bug 49335 - PIPESTATUS variable not set
Summary: PIPESTATUS variable not set
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 8.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Aaron Brown
: 49336 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2001-07-18 05:54 UTC by j. alan eldridge
Modified: 2007-04-18 16:34 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2002-12-06 17:11:28 UTC

Attachments (Terms of Use)

Description j. alan eldridge 2001-07-18 05:54:12 UTC
Description of Problem:

              An  array  variable (see Arrays below) containing a
              list of exit status values from  the  processes  in
              the   most-recently-executed   foreground  pipeline
              (which may contain only a single command).

How Reproducible:

[alane@wwweasel alane]$ false
[alane@wwweasel alane]$ echo $?
[alane@wwweasel alane]$ false|false
[alane@wwweasel alane]$ echo ${#PIPESTATUS[*]}
[alane@wwweasel alane]$ false|false
[alane@wwweasel alane]$ echo $PIPESTATUS
[alane@wwweasel alane]$ rpm -q bash
[alane@wwweasel alane]$ set | grep BASH
BASH_VERSINFO=([0]="2" [1]="05" [2]="8" [3]="1" [4]="release" 
[alane@wwweasel alane]$

Does this have to enabled by an option to configure when bash is built?

Additional Notes:

I would be very surprised if this problem does not exist in the release 
RPMS of bash as well, unless something obvious has changed very recently.

Comment 1 Bernhard Rosenkraenzer 2001-07-18 10:17:51 UTC
*** Bug 49336 has been marked as a duplicate of this bug. ***

Comment 2 Tim Waugh 2002-10-11 10:57:09 UTC
Still happens in Red Hat Linux 8.0.

Comment 3 Wayne Pollock 2002-12-05 21:47:52 UTC
The Bash builtin PIPESTATUS works as advertized UNLESS  you are at
a login shell.  Here is the output that shows this on an up2date RH 7.2

/faculty/wpollock> uname -a
Linux localhost 2.4.18-18.7.x #1 Wed Nov 13 20:29:30 EST 2002 i686 unknown
/home/wpollock> bash --version
GNU bash, version 2.05.8(1)-release (i386-redhat-linux-gnu)
Copyright 2000 Free Software Foundation, Inc.
/home/wpollock> who | grep nobodyishome | sort
/home/wpollock> echo ${PIPESTATUS[*]}
/home/wpollock> bash
(2) /home/wpollock> who | grep nobodyishome | sort
(2) /home/wpollock> echo ${PIPESTATUS[*]}
0 1 0
(2) /faculty/wpollock>

Comment 4 Wayne Pollock 2002-12-06 17:11:16 UTC
Followup:  Chet Ramsey solved this one:  PIPESTATUS always works, only sometimes the last command run isn't
what you might think.  In my case I had "PROMPT_COMMAND" shell variable set, which runs the command every
time a prompt is displayed.  By unsetting PROMPT_COMMAND PIPESTATUS worked as expected.

Comment 5 Wayne Pollock 2002-12-12 14:11:44 UTC
Maybe its not technically a bug, but PIPESTATUS should NOT be reset by internal Bash processes such as
when displaying a prompt.  No user will expect that, and it is only useful whne debugging Bash itself.
Most users expect PIPSTATUS to be set by the last command explicitly run by the user.  This bug shoul
 be converted to a request for enhancement, not just closed.

Note You need to log in before you can comment on or make changes to this bug.