fix for local variable problem in EXIT trap; add sed-like behavior for null patterns in pattern substitution

This commit is contained in:
Chet Ramey
2022-07-19 11:42:23 -04:00
parent 87a6e89edc
commit 52ae6c3f5d
12 changed files with 125 additions and 45 deletions
+24 -6
View File
@@ -1,6 +1,6 @@
/* variables.c -- Functions for hacking shell variables. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -330,6 +330,8 @@ static void push_func_var PARAMS((PTR_T));
static void push_builtin_var PARAMS((PTR_T));
static void push_exported_var PARAMS((PTR_T));
static void delete_local_contexts PARAMS((VAR_CONTEXT *));
/* This needs to be looked at again. */
static inline void push_posix_tempvar_internal PARAMS((SHELL_VAR *, int));
@@ -5427,10 +5429,8 @@ pop_var_context ()
internal_error (_("pop_var_context: no global_variables context"));
}
/* Delete the HASH_TABLEs for all variable contexts beginning at VCXT, and
all of the VAR_CONTEXTs except GLOBAL_VARIABLES. */
void
delete_all_contexts (vcxt)
static void
delete_local_contexts (vcxt)
VAR_CONTEXT *vcxt;
{
VAR_CONTEXT *v, *t;
@@ -5439,12 +5439,30 @@ delete_all_contexts (vcxt)
{
t = v->down;
dispose_var_context (v);
}
}
}
/* Delete the HASH_TABLEs for all variable contexts beginning at VCXT, and
all of the VAR_CONTEXTs except GLOBAL_VARIABLES. */
void
delete_all_contexts (vcxt)
VAR_CONTEXT *vcxt;
{
delete_local_contexts (vcxt);
delete_all_variables (global_variables->table);
shell_variables = global_variables;
}
/* Reset the context so we are not executing in a shell function. Only call
this if you are getting ready to exit the shell. */
void
reset_local_contexts ()
{
delete_local_contexts (shell_variables);
shell_variables = global_variables;
variable_context = 0;
}
/* **************************************************************** */
/* */
/* Pushing and Popping temporary variable scopes */