bug-bash
[Top][All Lists]
Advanced

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

pipefail option doesn't work as advertised


From: ben
Subject: pipefail option doesn't work as advertised
Date: Wed, 18 Aug 2004 14:32:52 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux berdoo 2.4.22 #2 Mon Jul 19 12:08:51 BST 2004 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

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

Description:
When using the pipefail option, the following command:
  echo foo | false
produces an exit status of 0, ignoring the exit status of false.

Fix:
The following patch fixes the problem:
diff -ur bash-3.0/jobs.c bash-3.0-fixed/jobs.c
--- bash-3.0/jobs.c     Fri Apr 23 21:28:25 2004
+++ bash-3.0-fixed/jobs.c       Wed Aug 18 14:32:19 2004
@@ -1778,8 +1778,11 @@
   if (pipefail_opt)
     {
       fail = 0;
-      for (p = jobs[job]->pipe; p->next != jobs[job]->pipe; p =
p->next)
-        if (p->status != EXECUTION_SUCCESS) fail = p->status;
+      p = jobs[job]->pipe;
+      do {
+       if (p->status != EXECUTION_SUCCESS) fail = p->status;
+       p=p->next;
+      } while(p!=jobs[job]->pipe);
       return fail;
     }





reply via email to

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