aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/evalstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/evalstring.c')
-rw-r--r--builtins/evalstring.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtins/evalstring.c b/builtins/evalstring.c
index 88d6a9e..04afac3 100644
--- a/builtins/evalstring.c
+++ b/builtins/evalstring.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Evaluate a string as one or more shell commands.
+
+ Copyright (C) 1996-2005 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -58,6 +60,7 @@ extern int indirection_level, startup_state, subshell_environment;
extern int line_number;
extern int last_command_exit_value;
extern int running_trap;
+extern int loop_level;
extern int posixly_correct;
int parse_and_execute_level = 0;
@@ -105,6 +108,7 @@ parse_and_execute (string, from_file, flags)
unwind_protect_jmp_buf (top_level);
unwind_protect_int (indirection_level);
unwind_protect_int (line_number);
+ unwind_protect_int (loop_level);
if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
unwind_protect_int (interactive);
@@ -231,17 +235,21 @@ parse_and_execute (string, from_file, flags)
* IF
* we were invoked as `bash -c' (startup_state == 2) AND
* parse_and_execute has not been called recursively AND
+ * we're not running a trap AND
* we have parsed the full command (string == '\0') AND
* we have a simple command without redirections AND
- * the command is not being timed
+ * the command is not being timed AND
+ * the command's return status is not being inverted
* THEN
* tell the execution code that we don't need to fork
*/
if (startup_state == 2 && parse_and_execute_level == 1 &&
+ running_trap == 0 &&
*bash_input.location.string == '\0' &&
command->type == cm_simple &&
!command->redirects && !command->value.Simple->redirects &&
- ((command->flags & CMD_TIME_PIPELINE) == 0))
+ ((command->flags & CMD_TIME_PIPELINE) == 0) &&
+ ((command->flags & CMD_INVERT_RETURN) == 0))
{
command->flags |= CMD_NO_FORK;
command->value.Simple->flags |= CMD_NO_FORK;