mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-07 04:10:49 +02:00
commit bash-20141128 snapshot
This commit is contained in:
+47
-12
@@ -100,6 +100,18 @@ extern int errno;
|
||||
# include "bashhist.h"
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
struct func_array_state
|
||||
{
|
||||
ARRAY *funcname_a;
|
||||
SHELL_VAR *funcname_v;
|
||||
ARRAY *source_a;
|
||||
SHELL_VAR *source_v;
|
||||
ARRAY *lineno_a;
|
||||
SHELL_VAR *lineno_v;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern int dollar_dollar_pid;
|
||||
extern int posixly_correct;
|
||||
extern int expand_aliases;
|
||||
@@ -4461,6 +4473,25 @@ maybe_restore_getopt_state (gs)
|
||||
free (gs);
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
static void
|
||||
restore_funcarray_state (fa)
|
||||
struct func_array_state *fa;
|
||||
{
|
||||
SHELL_VAR *nfv;
|
||||
ARRAY *funcname_a;
|
||||
|
||||
array_pop (fa->source_a);
|
||||
array_pop (fa->lineno_a);
|
||||
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
|
||||
if (nfv == fa->funcname_v)
|
||||
array_pop (funcname_a);
|
||||
|
||||
free (fa);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
execute_function (var, words, flags, fds_to_close, async, subshell)
|
||||
SHELL_VAR *var;
|
||||
@@ -4477,6 +4508,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
|
||||
ARRAY *funcname_a;
|
||||
volatile ARRAY *bash_source_a;
|
||||
volatile ARRAY *bash_lineno_a;
|
||||
struct func_array_state *fa;
|
||||
#endif
|
||||
FUNCTION_DEF *shell_fn;
|
||||
char *sfile, *t;
|
||||
@@ -4591,6 +4623,18 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
|
||||
free (t);
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
fa = (struct func_array_state *)xmalloc (sizeof (struct func_array_state));
|
||||
fa->source_a = bash_source_a;
|
||||
fa->source_v = bash_source_v;
|
||||
fa->lineno_a = bash_lineno_a;
|
||||
fa->lineno_v = bash_lineno_v;
|
||||
fa->funcname_a = funcname_a;
|
||||
fa->funcname_v = funcname_v;
|
||||
if (subshell == 0)
|
||||
add_unwind_protect (restore_funcarray_state, fa);
|
||||
#endif
|
||||
|
||||
/* The temporary environment for a function is supposed to apply to
|
||||
all commands executed within the function body. */
|
||||
|
||||
@@ -4668,20 +4712,11 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
|
||||
|
||||
if (subshell == 0)
|
||||
run_unwind_frame ("function_calling");
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
/* These two variables cannot be unset, and cannot be affected by the
|
||||
function. */
|
||||
array_pop ((ARRAY *)bash_source_a);
|
||||
array_pop ((ARRAY *)bash_lineno_a);
|
||||
|
||||
/* FUNCNAME can be unset, and so can potentially be changed by the
|
||||
function. */
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
|
||||
if (nfv == funcname_v)
|
||||
array_pop (funcname_a);
|
||||
else
|
||||
restore_funcarray_state (fa);
|
||||
#endif
|
||||
|
||||
|
||||
if (variable_context == 0 || this_shell_function == 0)
|
||||
{
|
||||
make_funcname_visible (0);
|
||||
|
||||
Reference in New Issue
Block a user