[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bash-bug] [bash-bug] PIPESTATUS always returns only a single elemen
From: |
Dr. Werner Fink |
Subject: |
Re: [bash-bug] [bash-bug] PIPESTATUS always returns only a single element |
Date: |
Mon, 16 Aug 2010 16:03:23 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Fri, Aug 13, 2010 at 12:18:23PM +0200, Werner Fink wrote:
> On Thu, Aug 12, 2010 at 05:37:55PM -0500, lsteeger@gmail.com wrote:
> > #!/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
The attached patch should do a better job, nevertheless IMHO there
could be a better solution. This could require some more work
on the COMMAND API to avoid things like
add_process((char*)0, getpid());
in execute_cmd.c, also the addjstatus() function is more like
a workaround to get the status back into the JOB/PROCESS API.
Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
bash-4.1-pipe.dif
Description: Text Data