Bug 49335 - PIPESTATUS variable not set
PIPESTATUS variable not set
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Aaron Brown
: 49336 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2001-07-18 01:54 EDT by j. alan eldridge
Modified: 2007-04-18 12:34 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-06 12:11:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description j. alan eldridge 2001-07-18 01:54:12 EDT
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 06:17:51 EDT
*** Bug 49336 has been marked as a duplicate of this bug. ***
Comment 2 Tim Waugh 2002-10-11 06:57:09 EDT
Still happens in Red Hat Linux 8.0.
Comment 3 Wayne Pollock 2002-12-05 16:47:52 EST
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 12:11:16 EST
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 09:11:44 EST
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.