bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: failure in pipeline not reflected in $?


From: Chris F.A. Johnson
Subject: Re: failure in pipeline not reflected in $?
Date: Thu, 25 Aug 2005 02:02:40 -0400 (EDT)

On Wed, 24 Aug 2005 cell@ices.utexas.edu 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" "${PIPESTATUS[@]}"
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>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]