bug-bash
[Top][All Lists]
Advanced

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

Re: Strange change between bash-3.2 and bash-4.0


From: Roman Rakus
Subject: Re: Strange change between bash-3.2 and bash-4.0
Date: Tue, 10 Feb 2009 14:13:30 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Roman Rakus wrote:
Hi
there is simple script:
#!/bin/sh
echo foo|cat /nosuchfile
echo "here: $?"

executed by sh -e
In bash-3.2 we got:
cat: /nosuchfile: No such file or directory

but in bash-4.0:
cat: /nosuchfile: No such file or directory
here: 1


From execute_cmd.c:

/* 10/6/2008 -- added test for pipe_in and pipe_out because they indicate
the presence of a pipeline, and (until Posix changes things), a
pipeline failure should not cause the parent shell to exit on an
unsuccessful return status, even in the presence of errexit.. */

I'm not sure what Posix says

but it breaks the:
-e  Exit immediately if a command exits with a non-zero status.

For reference see https://bugzilla.redhat.com/show_bug.cgi?id=483385

The fix:
diff -up bash-4.0-rc1/execute_cmd.c.err bash-4.0-rc1/execute_cmd.c
--- bash-4.0-rc1/execute_cmd.c.err 2009-01-31 20:05:38.000000000 +0200
+++ bash-4.0-rc1/execute_cmd.c 2009-01-31 20:05:46.000000000 +0200
@@ -764,7 +764,7 @@ execute_command_internal (command, async

if (ignore_return == 0 && invert == 0 &&
((posixly_correct && interactive == 0 && special_builtin_failed) ||
- (exit_immediately_on_error && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)))
+ (exit_immediately_on_error && exec_result != EXECUTION_SUCCESS)))
{
last_command_exit_value = exec_result;
run_pending_traps ();


RR


If this stays as it is, bash will never exit immediately if a command (in this case pipeline) exits with a non-zero status.
RR




reply via email to

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