[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bash-bug] PIPESTATUS always returns only a single element
From: |
Dr. Werner Fink |
Subject: |
Re: [bash-bug] PIPESTATUS always returns only a single element |
Date: |
Fri, 13 Aug 2010 12:18:23 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Thu, Aug 12, 2010 at 05:37:55PM -0500, lsteeger@gmail.com wrote:
> 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.
Question: could it be that you're using the bash from
http://download.opensuse.org/repositories/shells/ or
http://download.opensuse.org/factory/ ?
Then you may see a side effect of the patch enabling that a pipe uses
only subshells left from that last pipe symbol. This makes things
work like
bash> echo 1 2 | read a b; echo $a $b
1 2
... please report such problems on the channels for opensuse.org.
Sorry Chet for the noise
Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr