- rl_display_search: don't call rl_redisplay_function before returning;
rl_message already calls it. Reported by
Frédéric Moulins <frederic@moulins.org>
+
+configure.ac
+ - bumped version to bash-5.2-rc2
+
+ 7/18
+ ----
+jobs.c
+ - set_job_control: don't bother calling tcgetpgrp if shell_tty < 0,
+ since it will just fail
+
+variables.c
+ - reset_local_contexts: new function, delete all context tables
+ associated with shell functions and set variable_context to 0.
+ Called when we want to stop executing in a shell function without
+ going through the pop_context chain with its side effects
+
+variables.h
+ - reset_local_contexts: extern declaration
+
+builtins/evalstring.c
+ - parse_and_execute: call reset_local_contexts instead of setting
+ variable_context to 0
+
+eval.c
+ - reader_loop: call reset_local_contexts in cases where the shell has
+ longjmped for a fatal error and errexit is enabled (ERREXIT), but
+ not for other cases, and especially not for the exit builtin,
+ instead of just setting variable_context to 0. Fixes issue originally
+ reported by Robert Stoll <robert.stoll@tegonal.com>
+
+subst.c
+ - pat_subst: implement sed-like behavior when presented with a null
+ pattern that's anchored at the start or end of the string, or when
+ presented with a null string: process the replacement string for `&'
+ and `\&' and substitute in the result as before. Patch from
+ Koichi Murase <myoga.murase@gmail.com>
these circumstances. Don't bother with cleanup here because
we don't want to run the function execution cleanup stuff
that will cause pop_context and other functions to run.
+ We call reset_local_contexts() instead, which just frees
+ context memory.
XXX - change that if we want the function context to be
unwound. */
if (exit_immediately_on_error && variable_context)
{
discard_unwind_frame ("pe_dispose");
- variable_context = 0; /* not in a function */
+ reset_local_contexts (); /* not in a function */
}
should_jump_to_top_level = 1;
goto out;
#! /bin/sh
-# From configure.ac for Bash 5.2, version 5.042.
+# From configure.ac for Bash 5.2, version 5.043.
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for bash 5.2-rc1.
+# Generated by GNU Autoconf 2.71 for bash 5.2-rc2.
#
# Report bugs to <bug-bash@gnu.org>.
#
# Identity of this package.
PACKAGE_NAME='bash'
PACKAGE_TARNAME='bash'
-PACKAGE_VERSION='5.2-rc1'
-PACKAGE_STRING='bash 5.2-rc1'
+PACKAGE_VERSION='5.2-rc2'
+PACKAGE_STRING='bash 5.2-rc2'
PACKAGE_BUGREPORT='bug-bash@gnu.org'
PACKAGE_URL=''
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bash 5.2-rc1 to adapt to many kinds of systems.
+\`configure' configures bash 5.2-rc2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bash 5.2-rc1:";;
+ short | recursive ) echo "Configuration of bash 5.2-rc2:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bash configure 5.2-rc1
+bash configure 5.2-rc2
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bash $as_me 5.2-rc1, which was
+It was created by bash $as_me 5.2-rc2, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
BASHVERS=5.2
-RELSTATUS=rc1
+RELSTATUS=rc2
case "$RELSTATUS" in
alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bash $as_me 5.2-rc1, which was
+This file was extended by bash $as_me 5.2-rc2, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-bash config.status 5.2-rc1
+bash config.status 5.2-rc2
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AC_REVISION([for Bash 5.2, version 5.042])dnl
+AC_REVISION([for Bash 5.2, version 5.043])dnl
define(bashvers, 5.2)
-define(relstatus, rc1)
+define(relstatus, rc2)
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
/* eval.c -- reading and evaluating commands. */
-/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
switch (code)
{
/* Some kind of throw to top_level has occurred. */
- case FORCE_EOF:
case ERREXIT:
+ if (exit_immediately_on_error)
+ reset_local_contexts (); /* not in a function */
+ case FORCE_EOF:
case EXITPROG:
case EXITBLTIN:
current_command = (COMMAND *)NULL;
- if (exit_immediately_on_error)
- variable_context = 0; /* not in a function */
EOF_Reached = EOF;
goto exec_done;
old = job_control;
job_control = arg;
- if (terminal_pgrp == NO_PID)
+ if (terminal_pgrp == NO_PID && shell_tty >= 0)
terminal_pgrp = tcgetpgrp (shell_tty);
/* If we're turning on job control we're going to want to know the shell's
{
$$ = $1;
if (need_here_doc)
- gather_here_documents ();
+ gather_here_documents (); /* XXX */
if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
{
INTERNAL_DEBUG (("LEGACY: parser: command substitution simple_list1 -> simple_list"));
else
$$ = command_connect ($1, (COMMAND *)NULL, '&');
if (need_here_doc)
- gather_here_documents ();
+ gather_here_documents (); /* XXX */
if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
{
INTERNAL_DEBUG (("LEGACY: parser: command substitution simple_list1 '&' -> simple_list"));
{
$$ = $1;
if (need_here_doc)
- gather_here_documents ();
+ gather_here_documents (); /* XXX */
if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
{
INTERNAL_DEBUG (("LEGACY: parser: command substitution simple_list1 ';' -> simple_list"));
* STRING and return the result.
* 3. A null STRING with a matching pattern means to append REP to
* STRING and return the result.
- * These don't understand or process `&' in the replacement string.
+ *
+ * These process `&' in the replacement string, like `sed' does when
+ * presented with a BRE of `^' or `$'.
*/
if ((pat == 0 || *pat == 0) && (mtype == MATCH_BEG || mtype == MATCH_END))
{
- replen = STRLEN (rep);
+ rstr = (mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2) : rep;
+ rslen = STRLEN (rstr);
l = STRLEN (string);
- ret = (char *)xmalloc (replen + l + 2);
- if (replen == 0)
+ ret = (char *)xmalloc (rslen + l + 2);
+ if (rslen == 0)
strcpy (ret, string);
else if (mtype == MATCH_BEG)
{
- strcpy (ret, rep);
- strcpy (ret + replen, string);
+ strcpy (ret, rstr);
+ strcpy (ret + rslen, string);
}
else
{
strcpy (ret, string);
- strcpy (ret + l, rep);
+ strcpy (ret + l, rstr);
}
+ if (rstr != rep)
+ free (rstr);
return (ret);
}
else if (*string == 0 && (match_pattern (string, pat, mtype, &s, &e) != 0))
- {
- replen = STRLEN (rep);
- ret = (char *)xmalloc (replen + 1);
- if (replen == 0)
- ret[0] = '\0';
- else
- strcpy (ret, rep);
- return (ret);
- }
+ return ((mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2) : savestring (rep));
ret = (char *)xmalloc (rsize = 64);
ret[0] = '\0';
let\&ee
let&ee
let&ee
+twoone
+&twoone
+onetwo
+one&two
+two
+&two
+otwone
+&twone
argv[1] = </>
argv[1] = </>
echo ${var//$pat/"$r3"}
echo ${var//$pat/"&"}
echo ${var//$pat/$r3}
+
+# these cases provide the same functionality as sed when given a BRE like
+# `^' or `$', or when passed a null input line
+one=one
+null=
+
+echo ${one/#/&two}
+echo ${one/#/\&two}
+
+echo ${one/%/&two}
+echo ${one/%/\&two}
+
+echo ${null/#/&two}
+echo ${null/#/\&two}
+
+echo ${one/#?/&two}
+echo ${one/#?/\&two}
/* 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.
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));
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;
{
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 */
/* variables.h -- data structures for 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.
extern int delete_var PARAMS((const char *, VAR_CONTEXT *));
extern int makunbound PARAMS((const char *, VAR_CONTEXT *));
extern int kill_local_variable PARAMS((const char *));
+
extern void delete_all_variables PARAMS((HASH_TABLE *));
extern void delete_all_contexts PARAMS((VAR_CONTEXT *));
+extern void reset_local_contexts PARAMS((void));
extern VAR_CONTEXT *new_var_context PARAMS((char *, int));
extern void dispose_var_context PARAMS((VAR_CONTEXT *));