]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
apply several fixes tagged for bash-5.3; use memfd_create in anon file open if availa...
authorChet Ramey <chet.ramey@case.edu>
Tue, 20 Jun 2023 15:35:05 +0000 (11:35 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 20 Jun 2023 15:35:05 +0000 (11:35 -0400)
13 files changed:
CWRU/CWRU.chlog
POSIX
bashline.c
doc/bash.info
doc/bashref.info
doc/bashref.texi
execute_cmd.c
lib/readline/kill.c
lib/sh/anonfile.c
lib/sh/shmatch.c
parse.y
subst.c
test.c

index 7ca101a7b971d0817a5aef4db60bc5547bed1cdf..5e88f380776738ee1c1d1aa3fb5779f79c1d807a 100644 (file)
@@ -4276,6 +4276,11 @@ expr.c
          subscripts if the shell compatibility level is greater than 51.
          Prompted by report from Corey Hickey <bugfood-ml@fatooh.org>
 
+subst.c
+       - string_list_pos_params, param_expand: make sure that $* is treated
+         the same as "$*" in here-document bodies that are being expanded.
+         From https://lists.gnu.org/archive/html/bug-bash/2022-09/msg00002.html
+
                                   11/1
                                   ----
 lib/readline/readline.c
@@ -6750,4 +6755,45 @@ variables.c
        - push_posix_tempvar_internal: call arrayar_copyval instead of using
          inline code
 
+                                  6/19
+                                  ----
+lib/sh/shmatch.c
+       - sh_regmatch: use builtin_find_indexed_array to allow a local copy
+         of BASH_REMATCH.
+         From https://lists.gnu.org/archive/html/bug-bash/2022-05/msg00052.html
+
+execute_cmd.c
+       - execute_in_subshell: tentative change to clear procsub list after
+         performing redirections, so nothing in a redirection can affect
+         what's in the subshell.
+         From https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00114.html
+
+test.c
+       - binary_operator: in posix mode, the < and > operators compare strings
+         using the current locale (strcoll).
+         From https://www.austingroupbugs.net/view.php?id=375
+
+bashline.c
+       - bash_default_completion: make sure that command completion adds the
+         trailing `/' suffix for directories even if the directory name is
+         the same as the common prefix of matches.
+         From https://lists.gnu.org/archive/html/bug-bash/2022-11/msg00034.html
+
+lib/readline/kill.c
+       - rl_vi_yank_pop: make repeated invocations of vi-yank-pop cycle
+         through the kill ring just like in emacs mode, even when point
+         is at the end of the line.
+         From https://lists.gnu.org/archive/html/bug-bash/2022-08/msg00105.html
+
+parse.y
+       - parse_comsub: set variables if the last token (last_read_token) is
+         `;', `\n', or `&', in addition to was_word
+       - parse_comsub: if the last read token was a newline (was_newline),
+         terminate the comsub with a newline instead of a semicolon; keeps
+         the line numbers more consistent.
+         From a report by Grisha Levit <grishalevit@gmail.com>
+
+lib/sh/anonfile.c
+       - anonopen: use memfd_create if it is available, fall through to
+         traditional Unix/POSIX implementation if it fails
 
diff --git a/POSIX b/POSIX
index b5b21d88ab104536d79bb9ec01b115dc4c25a065..b6d410a0f40f3af5f24157658c588f8edbddd388 100644 (file)
--- a/POSIX
+++ b/POSIX
@@ -313,7 +313,10 @@ The following list is what's changed when 'POSIX mode' is in effect:
      that a backslash preceding a double quote character will escape it
      and the backslash will be removed.
 
-  66. Command substitutions don't set the '?' special parameter.  The
+  66. The 'test' builtin compares strings using the current locale when
+     processing the '<' and '>' binary operators.
+
+  67. Command substitutions don't set the '?' special parameter.  The
      exit status of a simple command without a command word is still the
      exit status of the last command substitution that occurred while
      evaluating the variable assignments and redirections in that
index 6adc548e0a99a9a61f1d6ba7381326fe0ea0d210..80f6860369d9c628b32b143d0969f771d65f0cc3 100644 (file)
@@ -1863,8 +1863,7 @@ bash_default_completion (const char *text, int start, int end, int qc, int compf
              rl_completion_suppress_append = 1;
              rl_filename_completion_desired = 0;
            }
-#if 0
-         /* TAG:bash-5.3 jidanni@jidanni.org 11/11/2022 */
+#if 1
          else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) &&
                   matches[2] && STREQ (matches[1], matches[2]) && CMD_IS_DIR (matches[0]))
 #else
index 3077b1d0a1cd6f3210f349bea2ce07474978a9aa..0136f1298283661e1eaf7803b5e87f2b5cdae049 100644 (file)
@@ -7487,7 +7487,10 @@ startup files.
      that a backslash preceding a double quote character will escape it
      and the backslash will be removed.
 
-  66. Command substitutions don't set the '?' special parameter.  The
+  66. The 'test' builtin compares strings using the current locale when
+     processing the '<' and '>' binary operators.
+
+  67. Command substitutions don't set the '?' special parameter.  The
      exit status of a simple command without a command word is still the
      exit status of the last command substitution that occurred while
      evaluating the variable assignments and redirections in that
@@ -12865,61 +12868,61 @@ Node: Directory Stack Builtins\7f296813
 Node: Controlling the Prompt\7f301070
 Node: The Restricted Shell\7f304032
 Node: Bash POSIX Mode\7f306639
-Node: Shell Compatibility Mode\7f322429
-Node: Job Control\7f330670
-Node: Job Control Basics\7f331127
-Node: Job Control Builtins\7f336126
-Node: Job Control Variables\7f341918
-Node: Command Line Editing\7f343071
-Node: Introduction and Notation\7f344739
-Node: Readline Interaction\7f346359
-Node: Readline Bare Essentials\7f347547
-Node: Readline Movement Commands\7f349333
-Node: Readline Killing Commands\7f350290
-Node: Readline Arguments\7f352208
-Node: Searching\7f353249
-Node: Readline Init File\7f355432
-Node: Readline Init File Syntax\7f356690
-Node: Conditional Init Constructs\7f380478
-Node: Sample Init File\7f384671
-Node: Bindable Readline Commands\7f387792
-Node: Commands For Moving\7f388993
-Node: Commands For History\7f391041
-Node: Commands For Text\7f396032
-Node: Commands For Killing\7f399678
-Node: Numeric Arguments\7f402708
-Node: Commands For Completion\7f403844
-Node: Keyboard Macros\7f408032
-Node: Miscellaneous Commands\7f408717
-Node: Readline vi Mode\7f414752
-Node: Programmable Completion\7f415656
-Node: Programmable Completion Builtins\7f423433
-Node: A Programmable Completion Example\7f434550
-Node: Using History Interactively\7f439795
-Node: Bash History Facilities\7f440476
-Node: Bash History Builtins\7f443478
-Node: History Interaction\7f448499
-Node: Event Designators\7f452116
-Node: Word Designators\7f453467
-Node: Modifiers\7f455224
-Node: Installing Bash\7f457029
-Node: Basic Installation\7f458163
-Node: Compilers and Options\7f461882
-Node: Compiling For Multiple Architectures\7f462620
-Node: Installation Names\7f464309
-Node: Specifying the System Type\7f466415
-Node: Sharing Defaults\7f467129
-Node: Operation Controls\7f467799
-Node: Optional Features\7f468754
-Node: Reporting Bugs\7f479970
-Node: Major Differences From The Bourne Shell\7f481301
-Node: GNU Free Documentation License\7f498147
-Node: Indexes\7f523321
-Node: Builtin Index\7f523772
-Node: Reserved Word Index\7f530870
-Node: Variable Index\7f533315
-Node: Function Index\7f550446
-Node: Concept Index\7f564227
+Node: Shell Compatibility Mode\7f322552
+Node: Job Control\7f330793
+Node: Job Control Basics\7f331250
+Node: Job Control Builtins\7f336249
+Node: Job Control Variables\7f342041
+Node: Command Line Editing\7f343194
+Node: Introduction and Notation\7f344862
+Node: Readline Interaction\7f346482
+Node: Readline Bare Essentials\7f347670
+Node: Readline Movement Commands\7f349456
+Node: Readline Killing Commands\7f350413
+Node: Readline Arguments\7f352331
+Node: Searching\7f353372
+Node: Readline Init File\7f355555
+Node: Readline Init File Syntax\7f356813
+Node: Conditional Init Constructs\7f380601
+Node: Sample Init File\7f384794
+Node: Bindable Readline Commands\7f387915
+Node: Commands For Moving\7f389116
+Node: Commands For History\7f391164
+Node: Commands For Text\7f396155
+Node: Commands For Killing\7f399801
+Node: Numeric Arguments\7f402831
+Node: Commands For Completion\7f403967
+Node: Keyboard Macros\7f408155
+Node: Miscellaneous Commands\7f408840
+Node: Readline vi Mode\7f414875
+Node: Programmable Completion\7f415779
+Node: Programmable Completion Builtins\7f423556
+Node: A Programmable Completion Example\7f434673
+Node: Using History Interactively\7f439918
+Node: Bash History Facilities\7f440599
+Node: Bash History Builtins\7f443601
+Node: History Interaction\7f448622
+Node: Event Designators\7f452239
+Node: Word Designators\7f453590
+Node: Modifiers\7f455347
+Node: Installing Bash\7f457152
+Node: Basic Installation\7f458286
+Node: Compilers and Options\7f462005
+Node: Compiling For Multiple Architectures\7f462743
+Node: Installation Names\7f464432
+Node: Specifying the System Type\7f466538
+Node: Sharing Defaults\7f467252
+Node: Operation Controls\7f467922
+Node: Optional Features\7f468877
+Node: Reporting Bugs\7f480093
+Node: Major Differences From The Bourne Shell\7f481424
+Node: GNU Free Documentation License\7f498270
+Node: Indexes\7f523444
+Node: Builtin Index\7f523895
+Node: Reserved Word Index\7f530993
+Node: Variable Index\7f533438
+Node: Function Index\7f550569
+Node: Concept Index\7f564350
 \1f
 End Tag Table
 
index 31a7e346343432090543925079b9823dc8689174..033ecca3485e89f9a34268af042ed646fc39ba6e 100644 (file)
@@ -7488,7 +7488,10 @@ startup files.
      that a backslash preceding a double quote character will escape it
      and the backslash will be removed.
 
-  66. Command substitutions don't set the '?' special parameter.  The
+  66. The 'test' builtin compares strings using the current locale when
+     processing the '<' and '>' binary operators.
+
+  67. Command substitutions don't set the '?' special parameter.  The
      exit status of a simple command without a command word is still the
      exit status of the last command substitution that occurred while
      evaluating the variable assignments and redirections in that
@@ -12866,61 +12869,61 @@ Node: Directory Stack Builtins\7f297035
 Node: Controlling the Prompt\7f301295
 Node: The Restricted Shell\7f304260
 Node: Bash POSIX Mode\7f306870
-Node: Shell Compatibility Mode\7f322663
-Node: Job Control\7f330907
-Node: Job Control Basics\7f331367
-Node: Job Control Builtins\7f336369
-Node: Job Control Variables\7f342164
-Node: Command Line Editing\7f343320
-Node: Introduction and Notation\7f344991
-Node: Readline Interaction\7f346614
-Node: Readline Bare Essentials\7f347805
-Node: Readline Movement Commands\7f349594
-Node: Readline Killing Commands\7f350554
-Node: Readline Arguments\7f352475
-Node: Searching\7f353519
-Node: Readline Init File\7f355705
-Node: Readline Init File Syntax\7f356966
-Node: Conditional Init Constructs\7f380757
-Node: Sample Init File\7f384953
-Node: Bindable Readline Commands\7f388077
-Node: Commands For Moving\7f389281
-Node: Commands For History\7f391332
-Node: Commands For Text\7f396326
-Node: Commands For Killing\7f399975
-Node: Numeric Arguments\7f403008
-Node: Commands For Completion\7f404147
-Node: Keyboard Macros\7f408338
-Node: Miscellaneous Commands\7f409026
-Node: Readline vi Mode\7f415064
-Node: Programmable Completion\7f415971
-Node: Programmable Completion Builtins\7f423751
-Node: A Programmable Completion Example\7f434871
-Node: Using History Interactively\7f440119
-Node: Bash History Facilities\7f440803
-Node: Bash History Builtins\7f443808
-Node: History Interaction\7f448832
-Node: Event Designators\7f452452
-Node: Word Designators\7f453806
-Node: Modifiers\7f455566
-Node: Installing Bash\7f457374
-Node: Basic Installation\7f458511
-Node: Compilers and Options\7f462233
-Node: Compiling For Multiple Architectures\7f462974
-Node: Installation Names\7f464666
-Node: Specifying the System Type\7f466775
-Node: Sharing Defaults\7f467492
-Node: Operation Controls\7f468165
-Node: Optional Features\7f469123
-Node: Reporting Bugs\7f480342
-Node: Major Differences From The Bourne Shell\7f481676
-Node: GNU Free Documentation License\7f498525
-Node: Indexes\7f523702
-Node: Builtin Index\7f524156
-Node: Reserved Word Index\7f531257
-Node: Variable Index\7f533705
-Node: Function Index\7f550839
-Node: Concept Index\7f564623
+Node: Shell Compatibility Mode\7f322786
+Node: Job Control\7f331030
+Node: Job Control Basics\7f331490
+Node: Job Control Builtins\7f336492
+Node: Job Control Variables\7f342287
+Node: Command Line Editing\7f343443
+Node: Introduction and Notation\7f345114
+Node: Readline Interaction\7f346737
+Node: Readline Bare Essentials\7f347928
+Node: Readline Movement Commands\7f349717
+Node: Readline Killing Commands\7f350677
+Node: Readline Arguments\7f352598
+Node: Searching\7f353642
+Node: Readline Init File\7f355828
+Node: Readline Init File Syntax\7f357089
+Node: Conditional Init Constructs\7f380880
+Node: Sample Init File\7f385076
+Node: Bindable Readline Commands\7f388200
+Node: Commands For Moving\7f389404
+Node: Commands For History\7f391455
+Node: Commands For Text\7f396449
+Node: Commands For Killing\7f400098
+Node: Numeric Arguments\7f403131
+Node: Commands For Completion\7f404270
+Node: Keyboard Macros\7f408461
+Node: Miscellaneous Commands\7f409149
+Node: Readline vi Mode\7f415187
+Node: Programmable Completion\7f416094
+Node: Programmable Completion Builtins\7f423874
+Node: A Programmable Completion Example\7f434994
+Node: Using History Interactively\7f440242
+Node: Bash History Facilities\7f440926
+Node: Bash History Builtins\7f443931
+Node: History Interaction\7f448955
+Node: Event Designators\7f452575
+Node: Word Designators\7f453929
+Node: Modifiers\7f455689
+Node: Installing Bash\7f457497
+Node: Basic Installation\7f458634
+Node: Compilers and Options\7f462356
+Node: Compiling For Multiple Architectures\7f463097
+Node: Installation Names\7f464789
+Node: Specifying the System Type\7f466898
+Node: Sharing Defaults\7f467615
+Node: Operation Controls\7f468288
+Node: Optional Features\7f469246
+Node: Reporting Bugs\7f480465
+Node: Major Differences From The Bourne Shell\7f481799
+Node: GNU Free Documentation License\7f498648
+Node: Indexes\7f523825
+Node: Builtin Index\7f524279
+Node: Reserved Word Index\7f531380
+Node: Variable Index\7f533828
+Node: Function Index\7f550962
+Node: Concept Index\7f564746
 \1f
 End Tag Table
 
index 4b0082c2c3ee53b2ce7c117cf8c24cee63f786dd..c37300d5244d743002046e5a70d20fa6bfc5a71a 100644 (file)
@@ -8694,6 +8694,10 @@ undergoes expansion.
 That means, for example, that a backslash preceding a double quote
 character will escape it and the backslash will be removed.
 
+@item
+The @code{test} builtin compares strings using the current locale when
+processing the @samp{<} and @samp{>} binary operators.
+
 @item
 Command substitutions don't set the @samp{?} special parameter. The exit
 status of a simple command without a command word is still the exit status
index 7d3711ecb5cbfd4a5e6ddc20980bf662ebede9cc..6bc572c743b5ff2f03cada177fa18fd26d8c6933 100644 (file)
@@ -1705,9 +1705,8 @@ execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_o
 
       dispose_redirects (command->redirects);
       command->redirects = (REDIRECT *)NULL;
-#if 0
+#if 1
 #if defined (PROCESS_SUBSTITUTION) && defined (JOB_CONTROL)
-      /* TAG: bash-5.3 kre 10/24/2022 */
       if (user_subshell && command->type == cm_subshell)
        {
          procsub_clear ();
index 1dfe3c57c053c7dcd1d83f4525f6bb59070f29a1..0ba59ce5b96b84c0d0618ec46c620645f5aac85b 100644 (file)
@@ -569,7 +569,7 @@ rl_vi_yank_pop (int count, int key)
     }
 
   l = strlen (rl_kill_ring[rl_kill_index]);
-#if 0 /* TAG:readline-8.3 8/29/2022 matteopaolini1995@gmail.com */
+#if 1
   origpoint = rl_point;
   n = rl_point - l + 1;
 #else
@@ -577,7 +577,7 @@ rl_vi_yank_pop (int count, int key)
 #endif
   if (n >= 0 && STREQN (rl_line_buffer + n, rl_kill_ring[rl_kill_index], l))
     {
-#if 0 /* TAG:readline-8.3 */
+#if 1
       rl_delete_text (n, n + l);               /* remember vi cursor positioning */
       rl_point = origpoint - l;
 #else
index febc778f1585bb2aefce394b7a69519b411b3b74..560b8c8662657a0c02ae0364143dd4eacbf36ab9 100644 (file)
@@ -51,6 +51,15 @@ anonopen (const char *name, int flags, char **fn)
 {
   int fd, flag;
 
+#if defined (HAVE_MEMFD_CREATE)
+  /* "Names do not affect the behavior of the file descriptor." */
+  fd = memfd_create ("anonopen", 0);
+  if (fd >= 0)
+    return fd;
+  /* If memfd_create fails, we fall through to the unlinked-regular-file
+     implementation. */
+#endif
+
   /* Heuristic */
   flag = (name && *name == '/') ? MT_TEMPLATE : MT_USETMPDIR;
   fd = sh_mktmpfd (name, flag|MT_USERANDOM|MT_READWRITE|MT_UNLINK, fn);
index 6bcfc6035f7dfbf1b0cee2e1621a0f5636c75e28..4262e6564ad29647e6838487a8bec4b1dd65fbc7 100644 (file)
@@ -93,11 +93,11 @@ sh_regmatch (const char *string, const char *pattern, int flags)
   /* Store the parenthesized subexpressions in the array BASH_REMATCH.
      Element 0 is the portion that matched the entire regexp.  Element 1
      is the part that matched the first subexpression, and so on. */
-#if 1
+#if 0
+  /* This was the pre-bash-5.3 code. */
   unbind_global_variable_noref ("BASH_REMATCH");
   rematch = make_new_array_variable ("BASH_REMATCH");
 #else
-  /* TAG:bash-5.3 */
   rematch = builtin_find_indexed_array ("BASH_REMATCH", 1);
 #endif
   amatch = rematch ? array_cell (rematch) : (ARRAY *)0;
diff --git a/parse.y b/parse.y
index c139a4d7b0dc939fc91468f14886f6fa074899ee..c08b77f645fb2ec0a3d30fa61ed5dca0ed418528 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -4297,7 +4297,8 @@ static char *
 parse_comsub (int qc, int open, int close, size_t *lenp, int flags)
 {
   int peekc, r;
-  int start_lineno, dolbrace_spec, local_extglob, was_extpat, was_word;
+  int start_lineno, dolbrace_spec, local_extglob, was_extpat;
+  int was_word, was_newline, was_semi, was_amp;
   char *ret, *tcmd;
   size_t retlen;
   sh_parser_state_t ps;
@@ -4342,7 +4343,7 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags)
   save_parser_state (&ps);
 
   was_extpat = (parser_state & PST_EXTPAT);
-  was_word = 0;
+  was_word = was_newline = was_semi = was_amp = 0;
 
   /* State flags we don't want to persist into command substitutions. */
   parser_state &= ~(PST_REGEXP|PST_EXTPAT|PST_CONDCMD|PST_CONDEXPR|PST_COMPASSIGN);
@@ -4390,10 +4391,14 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags)
 
   if (open == '{')
     {
-      if (current_token == shell_eof_token &&
-           (last_read_token == ';' || last_read_token == '\n') &&
-           (token_before_that == WORD || token_before_that == ASSIGNMENT_WORD))
-       was_word = 1;
+      if (current_token == shell_eof_token)
+       {
+         was_semi = last_read_token == ';';
+         was_newline = last_read_token == '\n';
+         was_amp = last_read_token == '&';
+
+         was_word = (was_semi || was_newline) && (token_before_that == WORD || token_before_that == ASSIGNMENT_WORD);
+       }
     }
 
   if (need_here_doc > 0)
@@ -4488,7 +4493,9 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she
       ret = xmalloc (retlen + 4);
       ret[0] = (dolbrace_spec == '|') ? '|' : ' ';
       strcpy (ret + 1, tcmd);          /* ( */
-      if (was_word)
+      if (was_newline)
+       ret[retlen++] = '\n';
+      else if (was_word || was_semi)
        ret[retlen++] = ';';
       else if (lastc != '\n' && lastc != ';' && lastc != '&')
        ret[retlen++] = ';';
diff --git a/subst.c b/subst.c
index b93374b8eaf8a54343a62c7af81d087f9f93f4c3..11e7a00c942aa133526a45741abb35476bd5b04b 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3026,12 +3026,7 @@ string_list_pos_params (int pchar, WORD_LIST *list, int quoted, int pflags)
     {
       tlist = quote_list (list);
       word_list_remove_quoted_nulls (tlist);
-#if 0
-      ret = string_list (tlist);
-#else
-      /* TAG:bash-5.3 Aloxaf Yin 9/1/2022 */
       ret = string_list_dollar_star (tlist, 0, 0);
-#endif
     }
   else if (pchar == '*' && quoted == 0 && ifs_is_null) /* XXX */
     ret = expand_no_split_dollar_star ? string_list_dollar_star (list, quoted, 0) : string_list_dollar_at (list, quoted, 0);   /* Posix interp 888 */
@@ -10456,12 +10451,7 @@ param_expand (char *string, int *sindex, int quoted,
             quote the whole string, including the separators.  If IFS
             is unset, the parameters are separated by ' '; if $IFS is
             null, the parameters are concatenated. */
-#if 0
-         temp = (quoted & (Q_DOUBLE_QUOTES|Q_PATQUOTE)) ? string_list_dollar_star (list, quoted, 0) : string_list (list);
-#else
-         /* TAG:bash-5.3 Aloxaf Yin 9/1/2022 */
          temp = string_list_dollar_star (list, quoted, 0);
-#endif
          if (temp)
            {
              temp1 = (quoted & Q_DOUBLE_QUOTES) ? quote_string (temp) : temp;
diff --git a/test.c b/test.c
index 114941ccd2551e0262c5a5e245ca9aa8ff897f5e..2b12197a523035406f17fe135b0ed4c7a29c1ea5 100644 (file)
--- a/test.c
+++ b/test.c
@@ -436,7 +436,7 @@ binary_operator (void)
       ((w[0] == '>' || w[0] == '<') && w[1] == '\0') ||                /* <, > */
       (w[0] == '!' && w[1] == '=' && w[2] == '\0'))            /* != */
     {
-#if 0  /* TAG: bash-5.3 POSIX interp 375 11/9/2022 */
+#if 1  /* POSIX interp 375 11/9/2022 */
       value = binary_test (w, argv[pos], argv[pos + 2], (posixly_correct ? TEST_LOCALE : 0));
 #else
       value = binary_test (w, argv[pos], argv[pos + 2], 0);