commit bash-20190321 snapshot

This commit is contained in:
Chet Ramey
2019-03-22 09:08:20 -04:00
parent 15a23d4474
commit 6e5013142b
7 changed files with 105 additions and 11 deletions
+37
View File
@@ -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 <lessbug@qq.com>
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 <stephane.chazelas@gmail.com>
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
+18
View File
@@ -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 */
+1 -1
View File
@@ -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
+22 -2
View File
@@ -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++)
+2 -1
View File
@@ -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_ */
+22 -6
View File
@@ -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 ()
{
+3 -1
View File
@@ -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;
}