[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PIPESTATUS always returns only a single element
From: |
lsteeger |
Subject: |
PIPESTATUS always returns only a single element |
Date: |
Thu, 12 Aug 2010 17:37:55 -0500 (CDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/usr/src/packages/BUILD/bash-4.1
-L/usr/src/packages/BUILD/bash-4.1/../readline-6.1
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -fmessage-length=0 -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -g -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g
-std=gnu89 -Wuninitialized -Wextra -Wno-unprototyped-calls -Wno-switch-enum
-Wno-unused-variable -Wno-unused-parameter -ftree-loop-linear -pipe
-fprofile-use
uname output: Linux russte14 2.6.31.12-0.2-desktop #1 SMP PREEMPT 2010-03-16
21:25:39 +0100 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu
Bash Version: 4.1
Patch Level: 7
Release Status: release
Description:
PIPESTATUS never shows more than 1 array element after executing a
multiple command pipe
Repeat-By:
Execute the following script:
#!/bin/bash
#
# A script to test PIPESTATUS and pipefail
#
echo " cmd: set +o pipefail"
echo " pipe: ps -ef 2>&1 | grep "^\$USR" >/dev/null"
set +o pipefail
ps -ef 2>&1 | grep "^$USR" >/dev/null
echo "expect: PIPESTATUS = 1 0 \$? = 0; got: PIPESTATUS = ${PIPESTATUS[*]} \$?
= $?"
echo
echo " cmd: set -o pipefail"
echo " pipe: ps -ef 2>&1 | grep "^\$USR" >/dev/null"
set -o pipefail
ps -ef 2>&1 | grep "^$USR" >/dev/null
echo "expect: PIPESTATUS = 1 0 \$? = 1; got: PIPESTATUS = ${PIPESTATUS[*]} \$?
= $?"
echo
echo " pipe: ps aux 2>&1 | grep "^\$USER" >/dev/null"
ps aux 2>&1 | grep "^$USER" >/dev/null
echo "expect: PIPESTATUS = 0 0 \$? = 0; got: PIPESTATUS = ${PIPESTATUS[*]} \$?
= $?"
echo "expect: PIPESTATUS = 0 \$? = 0; got: PIPESTATUS = ${PIPESTATUS[*]} \$? =
$?"
#
# End of script
None of the 'got' results 'expect'ing multiple PIPESTATUS results work.
- PIPESTATUS always returns only a single element,
lsteeger <=