Description of Problem: PIPESTATUS 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 $? 1 [alane@wwweasel alane]$ false|false [alane@wwweasel alane]$ echo ${#PIPESTATUS[*]} 1 [alane@wwweasel alane]$ false|false [alane@wwweasel alane]$ echo $PIPESTATUS 0 [alane@wwweasel alane]$ rpm -q bash bash-2.05-8 [alane@wwweasel alane]$ set | grep BASH BASH=/bin/bash BASH_ENV=/home/alane/.bashrc BASH_VERSINFO=([0]="2" [1]="05" [2]="8" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu") BASH_VERSION=$'2.05.8(1)-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.
*** Bug 49336 has been marked as a duplicate of this bug. ***
Still happens in Red Hat Linux 8.0.
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 system: /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[*]} 0 /home/wpollock> bash (2) /home/wpollock> who | grep nobodyishome | sort (2) /home/wpollock> echo ${PIPESTATUS[*]} 0 1 0 (2) /faculty/wpollock>
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.
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.