commit bash-20170901 snapshot

This commit is contained in:
Chet Ramey
2017-09-11 09:24:36 -04:00
parent 560db36b30
commit a27e6ec35a
3 changed files with 34 additions and 4 deletions
+10
View File
@@ -14291,3 +14291,13 @@ builtins/read.def
- struct ttsave: make the attrs member a struct, not a pointer, to force
a structure copy that will survive a longjmp to another context.
Leaving it as a pointer to a local struct is not portable
9/10
----
execute_cmd.c
- execute_builtin: make sure that we set up the unwind-protect for
pop_scope (temporary_env is non-zero) so that the temporary env
is propagated to the current environment only for special builtins
(source/eval/unset) not run by the command builtin
(flags & CMD_COMMAND_BUILTIN == 0). Fixes bug reported by
Martijn Dekker <martijn@inlv.org>
+23 -3
View File
@@ -603,6 +603,16 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
#if defined (TIME_BEFORE_SUBSHELL)
if ((command->flags & CMD_TIME_PIPELINE) && user_subshell && asynchronous == 0)
{
command->flags |= CMD_FORCE_SUBSHELL;
exec_result = time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close);
currently_executing_command = (COMMAND *)NULL;
return (exec_result);
}
#endif
if (command->type == cm_subshell ||
(command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) ||
(shell_control_structure (command->type) &&
@@ -4510,10 +4520,11 @@ execute_builtin (builtin, words, flags, subshell)
int flags, subshell;
{
int result, eval_unwind, ignexit_flag, old_e_flag;
int isbltinenv;
int isbltinenv, should_keep;
char *error_trap;
error_trap = 0;
should_keep = 0;
/* The eval builtin calls parse_and_execute, which does not know about
the setting of flags, and always calls the execution functions with
@@ -4549,10 +4560,17 @@ execute_builtin (builtin, words, flags, subshell)
problem only with the `unset', `source' and `eval' builtins.
`mapfile' is a special case because it uses evalstring (same as
eval or source) to run its callbacks. */
/* SHOULD_KEEP is for the pop_scope call below; it only matters when
posixly_correct is set, but we should propagate the temporary environment
to the enclosing environment only for special builtins. */
isbltinenv = (builtin == source_builtin || builtin == eval_builtin || builtin == unset_builtin || builtin == mapfile_builtin);
should_keep = isbltinenv && builtin != mapfile_builtin;
#if defined (HISTORY) && defined (READLINE)
if (builtin == fc_builtin || builtin == read_builtin)
isbltinenv = 1;
{
isbltinenv = 1;
should_keep = 0;
}
#endif
if (isbltinenv)
@@ -4563,8 +4581,10 @@ execute_builtin (builtin, words, flags, subshell)
if (temporary_env)
{
push_scope (VC_BLTNENV, temporary_env);
if (flags & CMD_COMMAND_BUILTIN)
should_keep = 0;
if (subshell == 0)
add_unwind_protect (pop_scope, (flags & CMD_COMMAND_BUILTIN) ? 0 : "1");
add_unwind_protect (pop_scope, should_keep ? "1" : 0);
temporary_env = (HASH_TABLE *)NULL;
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.