[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PIPESTATUS always returns only a single element
From: |
Chet Ramey |
Subject: |
Re: PIPESTATUS always returns only a single element |
Date: |
Thu, 12 Aug 2010 20:00:32 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.11) Gecko/20100711 Lightning/1.0b1 Thunderbird/3.0.6 |
On 8/12/10 6:37 PM, lsteeger@gmail.com wrote:
> 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.
Interesting. I can't reproduce it.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/