change to binary file detection; fix for negative fractional read timeout; check more often for terminating signals in subshells; clear process substitutions in subshells; wait only for last procsub if `wait' is called without arguments

This commit is contained in:
Chet Ramey
2022-10-31 10:08:36 -04:00
parent 6711d2dc77
commit b48c234286
11 changed files with 5444 additions and 6957 deletions
+48
View File
@@ -4219,3 +4219,51 @@ execute_cmd.c
lib/readline/xmalloc.c
- memory_error_and_abort: add `const' qualifiers to the argument. Fix
from Markus Elfring <Markus.Elfring@web.de>
10/24
-----
general.c
- check_binary_file: check the first two lines for NULs if the first
line begins with a `#!'; otherwise check the first. From a discussion
and patch in https://savannah.gnu.org/support/?110744
(larsh@apache.org)
parse.y
- parse_matched_pair: set PST_NOERROR if we read to EOF without finding
a closing match and call parser_error; avoids redundant error
message
lib/sh/uconvert.c
- uconvert: RETURN: if ipart (integer part) is 0, but upart (fractional
part) is non-zero, multiply upart by mult so we don't lose the sign
for values in the range (-1, 0]. From a report by
izabera <izaberina@gmail.com>
execute_cmd.c
- execute_in_subshell: check for terminating signals before we return
to our caller, which will immediately exit, and before running any
exit trap (since termsig_handler will run any exit trap). Fixes bug
reported by Andrew Neff <andrew.neff@visionsystemsinc.com>
10/26
-----
lib/readline/complete.c
- rl_filename_completion_function: if the application doesn't supply
any directory hook functions, we need to handle the case where we
dequoted users_dirname and also tilde-expanded dirname. We choose
to tilde expand users_dirname rather than call the application
dequoting function again. Report and patch from
Stefan H. Holek <stefan@epy.co.at>
10/27
-----
execute_cmd.c
- execute_in_subshell: call procsub_clear in addition to clear_fifo_list,
since none of these process substitutions are children of this new
subshell
jobs.c
- wait_for_background_pids: call procsub_waitpid on the last procsub
created as long as it's the same as $!, then call reap_procsubs to
clean up the procsub list. Don't call procsub_waitall. Report from
Oguz İsmail Uysal <oguzismailuysal@gmail.com>
Vendored
+5363 -6941
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -135,6 +135,7 @@ sleep_builtin (WORD_LIST *list)
if (list->word && ISOPTION (list->word->word, '-'))
list = list->next;
/* Reject options and negative arguments */
if (*list->word->word == '-' || list->next) {
builtin_usage ();
return (EX_USAGE);
+10 -1
View File
@@ -1625,6 +1625,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
#endif
#if defined (PROCESS_SUBSTITUTION)
procsub_clear ();
clear_fifo_list (); /* XXX- we haven't created any FIFOs */
#endif
@@ -1671,7 +1672,12 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
dispose_redirects (command->redirects);
command->redirects = (REDIRECT *)NULL;
}
#if 0
/* TAG: bash-5.3 kre 10/24/2022 */
if (user_subshell && command->type == cm_subshell)
procsub_clear ();
#endif
}
if (command->type == cm_subshell)
tcom = command->value.Subshell->command;
@@ -1730,6 +1736,9 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
return_code = (return_code == EXECUTION_SUCCESS) ? EXECUTION_FAILURE
: EXECUTION_SUCCESS;
/* Check for terminating signals before we return to our caller, which we
expect to exit immediately anyway. */
CHECK_TERMSIG;
/* If we were explicitly placed in a subshell with (), we need
to do the `shell cleanup' things, such as running traps[0]. */
+4 -5
View File
@@ -683,21 +683,20 @@ check_binary_file (sample, sample_len)
int sample_len;
{
register int i;
int nline;
unsigned char c;
if (sample_len >= 4 && sample[0] == 0x7f && sample[1] == 'E' && sample[2] == 'L' && sample[3] == 'F')
return 1;
/* Generally we check the first line for NULs. If the first line looks like
a `#!' interpreter specifier, we just look for NULs anywhere in the
buffer. */
if (sample[0] == '#' && sample[1] == '!')
return (memchr (sample, '\0', sample_len) != NULL);
a `#!' interpreter specifier, we look for NULs in the first two lines. */
nline = (sample[0] == '#' && sample[1] == '!') ? 2 : 1;
for (i = 0; i < sample_len; i++)
{
c = sample[i];
if (c == '\n')
if (c == '\n' && --nline == 0)
return (0);
if (c == '\0')
return (1);
+4 -2
View File
@@ -2708,13 +2708,15 @@ wait_for_background_pids (ps)
}
#if defined (PROCESS_SUBSTITUTION)
procsub_waitall ();
if (last_procsub_child && last_procsub_child->pid != NO_PID && last_procsub_child->pid == last_asynchronous_pid)
procsub_waitpid (last_procsub_child->pid);
reap_procsubs (); /* closes fd */
#endif
/* POSIX.2 says the shell can discard the statuses of all completed jobs if
`wait' is called with no arguments. */
mark_dead_jobs_as_notified (1);
cleanup_dead_jobs ();
cleanup_dead_jobs (); /* calls procsub_prune */
bgp_clear ();
return njobs;
+11 -5
View File
@@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -2526,7 +2526,8 @@ rl_filename_completion_function (const char *text, int state)
temp = tilde_expand (dirname);
xfree (dirname);
dirname = temp;
tilde_dirname = 1;
if (*dirname != '~')
tilde_dirname = 1; /* indicate successful tilde expansion */
}
/* We have saved the possibly-dequoted version of the directory name
@@ -2545,11 +2546,16 @@ rl_filename_completion_function (const char *text, int state)
xfree (users_dirname);
users_dirname = savestring (dirname);
}
else if (tilde_dirname == 0 && rl_completion_found_quote && rl_filename_dequoting_function)
else if (rl_completion_found_quote && rl_filename_dequoting_function)
{
/* delete single and double quotes */
/* We already ran users_dirname through the dequoting function.
If tilde_dirname == 1, we successfully performed tilde expansion
on dirname. Now we need to reconcile those results. We either
just copy the already-dequoted users_dirname or tilde expand it
if we tilde-expanded dirname. */
temp = tilde_dirname ? tilde_expand (users_dirname) : savestring (users_dirname);
xfree (dirname);
dirname = savestring (users_dirname);
dirname = temp;
}
directory = opendir (dirname);
+1 -1
View File
@@ -40,7 +40,7 @@
#define RETURN(x) \
do { \
if (ip) *ip = ipart * mult; \
if (up) *up = upart; \
if (up) *up = upart * (ipart == 0 ? mult : 1); \
if (ep) *ep = p; \
return (x); \
} while (0)
+1
View File
@@ -3695,6 +3695,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
free (ret);
parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), close);
EOF_Reached = 1; /* XXX */
parser_state |= PST_NOERROR; /* avoid redundant error message */
return (&matched_pair_error);
}
+1 -1
View File
@@ -1,6 +1,6 @@
/* sig.c - interface for shell signal handlers and signal initialization. */
/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
/* Copyright (C) 1994-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
-1
View File
@@ -306,4 +306,3 @@ argv[1] = <"A">
argv[1] = <A>
argv[1] = <A>
./posixexp.tests: line 97: unexpected EOF while looking for matching `}'
./posixexp.tests: line 98: syntax error: unexpected end of file