Re: failure in pipeline not reflected in $?

2005-08-25 Thread Paul Jarc
[EMAIL PROTECTED] wrote:
 If a command in a pipeline of commands fails, there appears to be no
 way of knowing this.

Check the man page regarding the PIPESTATUS array.


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: failure in pipeline not reflected in $?

2005-08-25 Thread Chris F.A. Johnson

On Wed, 24 Aug 2005 [EMAIL PROTECTED] wrote:


Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu' 
-DCONF_VENDOR='mandrake' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H  -I.  -I.. -I../include -I../lib  -D_GNU_SOURCE  -O2 
-fomit-frame-pointer -pipe -march=i586 -mtune=pentiumpro
uname output: Linux block.ices.utexas.edu 2.6.11-6mdk #1 Tue Mar 22 16:04:32 
CET 2005 i686 AMD Athlon(TM) XP 2200+ unknown GNU/Linux
Machine Type: i586-mandrake-linux-gnu

Bash Version: 3.0
Patch Level: 16
Release Status: release

Description:
I am not sure if this is a bug, or if this is correct behavior.

   consider:

   false | true
   echo $?
   0

   If a command in a pipeline of commands fails, there appears to be no
   way of knowing this.  One alternate behavior to consider is to return
   the exit status of the first command in the pipeline to exit with non
   zero status.


The return codes are stored in the PIPESTATUS array:

$ false | true | false | true
$ printf %s\n [EMAIL PROTECTED]
1
0
1
0


--
Chris F.A. Johnson http://cfaj.freeshell.org
==
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
http://www.torfree.net/~chris/books/cfaj/ssr.html


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: failure in pipeline not reflected in $?

2005-08-25 Thread Jason Pepas
Thanks!  Sorry to waste your time with something which was in the man
page afterall.  This is exactly what I was looking for.

-jason pepas

On Thu, Aug 25, 2005 at 02:02:40AM -0400, Chris F.A. Johnson wrote:
 On Wed, 24 Aug 2005 [EMAIL PROTECTED] wrote:
 
 Configuration Information [Automatically generated, do not change]:
 Machine: i586
 OS: linux-gnu
 Compiler: gcc
 Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
 -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu' 
 -DCONF_VENDOR='mandrake' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
 -DSHELL -DHAVE_CONFIG_H  -I.  -I.. -I../include -I../lib  -D_GNU_SOURCE  
 -O2 -fomit-frame-pointer -pipe -march=i586 -mtune=pentiumpro
 uname output: Linux block.ices.utexas.edu 2.6.11-6mdk #1 Tue Mar 22 
 16:04:32 CET 2005 i686 AMD Athlon(TM) XP 2200+ unknown GNU/Linux
 Machine Type: i586-mandrake-linux-gnu
 
 Bash Version: 3.0
 Patch Level: 16
 Release Status: release
 
 Description:
  I am not sure if this is a bug, or if this is correct behavior.
 
consider:
 
false | true
echo $?
0
 
If a command in a pipeline of commands fails, there appears to be no
way of knowing this.  One alternate behavior to consider is to return
the exit status of the first command in the pipeline to exit with non
zero status.
 
 The return codes are stored in the PIPESTATUS array:
 
 $ false | true | false | true
 $ printf %s\n [EMAIL PROTECTED]
 1
 0
 1
 0
 
 
 -- 
 Chris F.A. Johnson http://cfaj.freeshell.org
 ==
 Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
 http://www.torfree.net/~chris/books/cfaj/ssr.html


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash