From 4f536430e45d847d6945133690312a8e94762254 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 1 Oct 2025 11:14:27 -0400 Subject: [PATCH] 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 --- CWRU/CWRU.chlog | 31 ++++++++++++++++++++++++++++++- bashline.c | 2 +- builtins/printf.def | 4 ++++ doc/bash.1 | 20 +++++++++++++++++--- doc/bashref.texi | 24 ++++++++++++++++-------- doc/version.texi | 4 ++-- examples/loadables/fltexpr.c | 6 +++++- execute_cmd.c | 2 +- parse.y | 2 ++ tests/execscript | 3 ++- 10 files changed, 80 insertions(+), 18 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index c223fbb0..4114d677 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -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 + + 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 diff --git a/bashline.c b/bashline.c index 1ee70358..e4f9975b 100644 --- a/bashline.c +++ b/bashline.c @@ -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; diff --git a/builtins/printf.def b/builtins/printf.def index 3c4335c4..2de73b54 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -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 diff --git a/doc/bash.1 b/doc/bash.1 index a00d4187..f82c130c 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -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 diff --git a/doc/bashref.texi b/doc/bashref.texi index 29908ca1..0ac623d1 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -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 diff --git a/doc/version.texi b/doc/version.texi index ae5d4449..7bf929f5 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -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 diff --git a/examples/loadables/fltexpr.c b/examples/loadables/fltexpr.c index 4576f3d2..5af6eeb8 100644 --- a/examples/loadables/fltexpr.c +++ b/examples/loadables/fltexpr.c @@ -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 diff --git a/execute_cmd.c b/execute_cmd.c index 006312d3..3a1c169e 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -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 } diff --git a/parse.y b/parse.y index b698f86b..615c3fe0 100644 --- a/parse.y +++ b/parse.y @@ -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'; diff --git a/tests/execscript b/tests/execscript index 0e652b1a..15a9da8f 100644 --- a/tests/execscript +++ b/tests/execscript @@ -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 -- 2.47.3