fix problem with completing filenames with user-supplied double quotes containing word expansion characters; fix problem with printf %S and precision overflow; fix issue with %P in TIMEFORMAT when timing null commands in posix mode; fix problem with SIGINT while parsing command substitutions

This commit is contained in:
Chet Ramey
2025-10-01 11:14:27 -04:00
parent fbd078be0a
commit 4f536430e4
10 changed files with 80 additions and 18 deletions
+30 -1
View File
@@ -11832,4 +11832,33 @@ builtins/read.def
-n/-N/-d options
- read_builtin: call check_read_input instead of input_avail if we
have a zero timeout
From a report by pourko@tutamail.com
Report from pourko@tutamail.com
bashline.c
- bash_quote_filename: if the user supplies an opening double quote
and the word being completed contains a `$' or ``', make sure there
is a single match and it doesn't exist as a filename before setting
the quoting style to COMPLETE_DQUOTE2.
This is similar to the change from 8/22.
Report from Koichi Murase <myoga.murase@gmail.com>
9/25
----
builtins/printf.def
- printwidestr: handle precision < 0 as an overflow return from
decodeint; don't adjust pr in this case so the string gets printed.
Same as fix to printstr from 7/8
Report from pourko@tutamail.com
9/29
----
execute_cmd.c
- time_command: if we don't have gettimeofday or getrusage, and we're
using times(3), make sure we convert from seconds to CLK_TCKs
when assigning tbefore from shell_start_time (use get_clk_tck())
Report from pourko2@tutamail.com
parse.y
- reset_parser: reset shell_eof_token to 0, rely on callers to restore
it if they need to
Report from Grisha Levit <grishalevit@gmail.com>
+1 -1
View File
@@ -4442,7 +4442,7 @@ bash_quote_filename (char *s, int rtype, char *qcp)
cs = COMPLETE_SQUOTE;
else if (*qcp == '"')
{
if ((expchar = bash_check_expchar (s, 0, &nextch, &closer)) == '$' || expchar == '`')
if (((expchar = bash_check_expchar (s, 0, &nextch, &closer)) == '$' || expchar == '`') && rtype == SINGLE_MATCH && file_exists (s) == 0)
cs = COMPLETE_DQUOTE2;
else
cs = COMPLETE_DQUOTE;
+4
View File
@@ -1016,7 +1016,11 @@ printwidestr (char *fmt, wchar_t *wstring, size_t len, int fieldwidth, int preci
pr = decodeint (&fmt, 1, -1);
/* pr < precision means we adjusted precision in printf_builtin
for the quoted string length (%Q), so we use the adjusted value */
#if 1 /*TAG:bash-5.4 20250702 */
if (pr >= 0 && pr < precision)
#else
if (pr < precision)
#endif
pr = precision;
}
else
+17 -3
View File
@@ -5,7 +5,7 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Sep 19 12:19:06 EDT 2025
.\" Last Change: Wed Sep 24 09:35:41 EDT 2025
.\"
.\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section
.\" For rbash, strip all but "RESTRICTED SHELL" section
@@ -21,7 +21,7 @@
.ds zY \" empty
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2025 September 19" "GNU Bash 5.3"
.TH BASH 1 "2025 September 24" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
@@ -4544,13 +4544,27 @@ include it as the first character in the set.
.IP
The sorting order of characters in range expressions,
and the characters included in the range,
are determined by the current locale and the values of the
are determined by the collating sequence of the
current locale and the values of the
.SM
.B LC_COLLATE
or
.SM
.B LC_ALL
shell variables, if set.
.IP
For example, in the C locale,
.B [a\-d]
is equivalent to
.BR [abcd] .
Many locales sort characters in dictionary order, and in these locales
.B [a\-d]
is typically not equivalent to
.BR [abcd] ;
it might be equivalent to
.B [aBbCcDd]
or
.BR [aAbBcCd] .
To obtain the traditional interpretation of range expressions, where
.B [a\-d]
is equivalent to
+16 -8
View File
@@ -3190,18 +3190,26 @@ character in the set.
The sorting order of characters in range expressions,
and the characters included in the range,
are determined by the current locale and the values of the
are determined by the collating sequence of the
current locale and the values of the
@env{LC_COLLATE} and @env{LC_ALL} shell variables, if set.
For example, in the default C locale, @samp{[a-dx-z]} is equivalent to
For example, in the default C locale,
@samp{[a-dx-z]}
is equivalent to
@samp{[abcdxyz]}.
Many locales sort characters in dictionary order, and in these locales
@samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
it might be equivalent to @samp{[aBbCcDdxYyZz]}, for example.
To obtain
the traditional interpretation of ranges in bracket expressions, you can
force the use of the C locale by setting the @env{LC_COLLATE} or
@env{LC_ALL} environment variable to the value @samp{C}, or enable the
@samp{[a-dx-z]}
is typically not equivalent to
@samp{[abcdxyz]};
it might be equivalent to
@samp{[aBbCcDdxYyZz]}
or
@samp{[aAbBcCdxXyYz]}.
To obtain the traditional interpretation of ranges in bracket expressions,
you can force the use of the C locale by setting the
@env{LC_COLLATE} or @env{LC_ALL}
environment variables to the value @samp{C}, or enable the
@code{globasciiranges} shell option.
Within a bracket expression, @dfn{character classes} can be specified
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2025 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Fri Sep 19 12:19:29 EDT 2025
@set LASTCHANGE Wed Sep 24 09:35:21 EDT 2025
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 19 September 2025
@set UPDATED 24 September 2025
@set UPDATED-MONTH September 2025
+5 -1
View File
@@ -1744,11 +1744,15 @@ fltexpr_builtin_unload (char *s)
char *fltexpr_doc[] =
{
"Evaluate floating-point arithmetic expression.",
"Evaluate a floating-point arithmetic expression.",
"",
"Evaluate EXPRESSION as a floating-point arithmetic expression and,",
"if the -p option is supplied, print the value to the standard output.",
"",
"Operators and precedence are similar to the let builtin (bitwise",
"operators and the modulus operator are not available). Calculations",
"are performed using C double-precision floating point values.",
"",
"Exit Status:",
"If the EXPRESSION evaluates to 0, the return status is 1; 0 otherwise.",
(char *)NULL
+1 -1
View File
@@ -1505,7 +1505,7 @@ time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, str
before = shellstart;
#else
before.tms_utime = before.tms_stime = before.tms_cutime = before.tms_cstime = 0;
tbefore = shell_start_time;
tbefore = shell_start_time * get_clk_tck ();
#endif
}
+2
View File
@@ -3558,6 +3558,8 @@ reset_parser (void)
simplecmd_lineno = line_number;
shell_eof_token = 0; /* no longer parsing command substitution */
current_token = '\n'; /* XXX */
last_read_token = '\n';
token_to_read = '\n';
+2 -1
View File
@@ -167,7 +167,8 @@ ${THIS_SH} -c 'VAR=0; VAR=1 command exec; exit ${VAR}'
exec /var/empty/nosuch
echo bad
) 2>/dev/null
[ $? = 127 ] || echo FAIL: bad exit status $? at $LINENO
r=$?
[ $r = 127 ] || echo FAIL: bad exit status $r at $LINENO
unset FALSE
if [ -x /bin/false ]; then