From 6e5013142bf797f3a3107ef9c688931fe774c86b Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Fri, 22 Mar 2019 09:08:20 -0400 Subject: [PATCH] commit bash-20190321 snapshot --- CWRU/CWRU.chlog | 37 +++++++++++++++++++++++++++++++++++++ execute_cmd.c | 18 ++++++++++++++++++ lib/readline/misc.c | 2 +- lib/sh/strtrans.c | 24 ++++++++++++++++++++++-- patchlevel.h | 3 ++- subst.c | 28 ++++++++++++++++++++++------ variables.c | 4 +++- 7 files changed, 105 insertions(+), 11 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 4526e344e..ab18ef22e 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -5589,3 +5589,40 @@ subst.c - chk_atstar: if we see "$*" don't note that we saw $@ unless expand_no_split_dollar_star is unset. This is what param_expand does + + 3/18 + ---- +lib/readline/misc.c + - rl_get_previous_history: if we are trying to go back from the + beginning of the history, or if we are trying to go back before the + beginning of the history, call _rl_free_saved_history_line to just + get rid of the history line we saved instead of using + rl_maybe_unsave_line, which modifies the current line buffer. + Fixes bug reported by lessbug + + 3/20 + ---- +execute_cmd.c + - execute_command_internal: save and restore line_number around + user_subshell setting it to the line number saved in the command. + Fixes bug reported in https://bugzilla.novell.com/show_bug.cgi?id=1128936 + + 3/21 + ---- +lib/sh/strtrans.c + - ansicstr: handle multibyte characters that are not preceded by a + backslash so we skip over potential escapes in characters whose + multibyte representation contains a backslash. Fixes issue reported by + Stephane Chazelas + +subst.c + - reap_some_procsubs: reap_procsubs, but parameterized to take the + max index to check -- general function for future use + - reap_procsubs: now just calls reap_some_procsubs with the right arg + +execute_cmd.c + - execute_command_internal: if we are using /dev/fd for process + substitution, reap the procsubs at the end of this function (FIFOs + do it at the beginning -- look at this more closely). Only do it + for loops to avoid fd exhaustion. Fixes bug reported by + sunnycemetery@gmail.com diff --git a/execute_cmd.c b/execute_cmd.c index e4a05e2ed..7f5f41f6c 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -624,6 +624,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, /* Fork a subshell, turn off the subshell bit, turn off job control and call execute_command () on the command again. */ + save_line_number = line_number; if (command->type == cm_subshell) line_number_for_err_trap = line_number = command->value.Subshell->line; /* XXX - save value? */ /* Otherwise we defer setting line_number */ @@ -677,6 +678,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, stop_pipeline (asynchronous, (COMMAND *)NULL); + line_number = save_line_number; + if (asynchronous == 0) { was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; @@ -1103,6 +1106,21 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, free ((void *)ofifo_list); discard_unwind_frame ("internal_fifos"); } +# if defined (HAVE_DEV_FD) + /* Reap process substitutions at the end of loops */ + switch (command->type) + { + case cm_while: + case cm_until: + case cm_for: +# if defined (ARITH_FOR_COMMAND) + case cm_arith_for: +# endif + reap_procsubs (); + default: + break; + } +# endif /* HAVE_DEV_FD */ #endif /* Invert the return value if we have to */ diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 6c993f5dc..5e7979312 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -624,7 +624,7 @@ rl_get_previous_history (int count, int key) if (temp == 0) { - rl_maybe_unsave_line (); + _rl_free_saved_history_line (); rl_ding (); } else diff --git a/lib/sh/strtrans.c b/lib/sh/strtrans.c index 48f255f5d..b2b1acca3 100644 --- a/lib/sh/strtrans.c +++ b/lib/sh/strtrans.c @@ -55,12 +55,18 @@ ansicstr (string, len, flags, sawc, rlen) int c, temp; char *ret, *r, *s; unsigned long v; + size_t clen; + int b, mb_cur_max; +#if defined (HANDLE_MULTIBYTE) + wchar_t wc; +#endif if (string == 0 || *string == '\0') return ((char *)NULL); + mb_cur_max = MB_CUR_MAX; #if defined (HANDLE_MULTIBYTE) - temp = 4*len + 1; + temp = 4*len + 4; if (temp < 12) temp = 12; /* ensure enough for eventual u32cesc */ ret = (char *)xmalloc (temp); @@ -71,7 +77,21 @@ ansicstr (string, len, flags, sawc, rlen) { c = *s++; if (c != '\\' || *s == '\0') - *r++ = c; + { + clen = 1; +#if defined (HANDLE_MULTIBYTE) + if ((locale_utf8locale && (c & 0x80)) || + (locale_utf8locale == 0 && mb_cur_max > 0 && is_basic (c) == 0)) + { + clen = mbrtowc (&wc, s - 1, mb_cur_max, 0); + if (MB_INVALIDCH (clen)) + clen = 1; + } +#endif + *r++ = c; + for (--clen; clen > 0; clen--) + *r++ = *s++; + } else { switch (c = *s++) diff --git a/patchlevel.h b/patchlevel.h index a988d8526..4c9998e61 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,7 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 2 +#define PATCHLEVEL 3 #endif /* _PATCHLEVEL_H_ */ + diff --git a/subst.c b/subst.c index 62a3b3755..47d9dbc8b 100644 --- a/subst.c +++ b/subst.c @@ -5321,6 +5321,8 @@ parameter_brace_remove_pattern (varname, value, ind, patstr, rtype, quoted, flag #if defined (PROCESS_SUBSTITUTION) +static void reap_some_procsubs __P((int)); + /*****************************************************************/ /* */ /* Hacking Process Substitution */ @@ -5482,16 +5484,23 @@ set_procsub_status (ind, pid, status) /* If we've marked the process for this procsub as dead, close the associated file descriptor and delete the FIFO. */ -void -reap_procsubs () +static void +reap_some_procsubs (max) + int max; { int i; - for (i = 0; i < nfifo; i++) + for (i = 0; i < max; i++) if (fifo_list[i].proc == (pid_t)-1) /* reaped */ unlink_fifo (i); } +void +reap_procsubs () +{ + reap_some_procsubs (nfifo); +} + void wait_procsubs () { @@ -5708,16 +5717,23 @@ set_procsub_status (ind, pid, status) /* If we've marked the process for this procsub as dead, close the associated file descriptor. */ -void -reap_procsubs () +static void +reap_some_procsubs (max) + int max; { int i; - for (i = 0; nfds > 0 && i < totfds; i++) + for (i = 0; nfds > 0 && i < max; i++) if (dev_fd_list[i] == (pid_t)-1) unlink_fifo (i); } +void +reap_procsubs () +{ + reap_some_procsubs (totfds); +} + void wait_procsubs () { diff --git a/variables.c b/variables.c index 90c16d875..00118bdaf 100644 --- a/variables.c +++ b/variables.c @@ -4465,7 +4465,8 @@ push_posix_temp_var (data) #if 0 /* TAG:bash-5.1 */ /* Just like do_assignment_internal(). This makes assignments preceding special builtins act like standalone assignment statements when in - posix mode. */ + posix mode, satisfying the posix requirement that this affect the + "current execution environment." */ v = bind_variable (var->name, value_cell (var), ASS_FORCE|ASS_NOLONGJMP); /* If this modifies an existing local variable, v->context will be non-zero. @@ -5148,6 +5149,7 @@ push_var_context (name, flags, tempvars) vc->table = tempvars; /* Have to do this because the temp environment was created before variable_context was incremented. */ + /* XXX - only need to do it if flags&VC_FUNCENV */ flatten (tempvars, set_context, (VARLIST *)NULL, 0); vc->flags |= VC_HASTMPVAR; } -- 2.47.2