]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix parser problem with auto-setting extglob inside command substitution inside condi...
authorChet Ramey <chet.ramey@case.edu>
Tue, 30 Aug 2022 15:42:30 +0000 (11:42 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 30 Aug 2022 15:42:30 +0000 (11:42 -0400)
CWRU/CWRU.chlog
lib/readline/kill.c
parse.y

index 0de19642c966956da9a589d8e1d185c95ad54ecb..317a9460343bb330bb837e535b3df818e434dadc 100644 (file)
@@ -3904,4 +3904,13 @@ builtins/exec.def
          command is not found by search_for_command. Report and fix from
          Xiami <i@f2light.com>
 
-         
+[bash-5.2-rc3 frozen]
+
+                                  8/27
+                                  ----
+parse.y
+       - parse_comsub: restore extended_glob to a local copy (local_extglob)
+         only if we changed it; a safer way to do it. Fixes extglob change
+         issue reported by Kerin Millar <kfm@plushkava.net>
+       - cond_term: restore extended_glob to a local copy; safer than using
+         global_extglob, which we will reserve for error recovery
index 61b744c96dc6d14fd6f282e85230524235aa532d..4cf933b20096ec0ceafa573fa3f06d43f4a178af 100644 (file)
@@ -559,7 +559,7 @@ rl_yank_pop (int count, int key)
 int
 rl_vi_yank_pop (int count, int key)
 {
-  int l, n;
+  int l, n, origpoint;
 
   if (((rl_last_func != rl_vi_yank_pop) && (rl_last_func != rl_vi_put)) ||
       !rl_kill_ring)
@@ -569,11 +569,21 @@ 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 */
+  origpoint = rl_point;
+  n = rl_point - l + 1;
+#else
   n = rl_point - l;
+#endif
   if (n >= 0 && STREQN (rl_line_buffer + n, rl_kill_ring[rl_kill_index], l))
     {
+#if 0 /* TAG:readline-8.3 */
+      rl_delete_text (n, n + l);               /* remember vi cursor positioning */
+      rl_point = origpoint - l;
+#else
       rl_delete_text (n, rl_point);
       rl_point = n;
+#endif
       rl_kill_index--;
       if (rl_kill_index < 0)
        rl_kill_index = rl_kill_ring_length - 1;
diff --git a/parse.y b/parse.y
index 7e82d3de6f404e439a0655223c3a4572cf65ba01..4922d12951d6921ce71a146f4610b6f7f8d7f4bf 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -4063,7 +4063,7 @@ parse_comsub (qc, open, close, lenp, flags)
      int *lenp, flags;
 {
   int peekc, r;
-  int start_lineno;
+  int start_lineno, local_extglob;
   char *ret, *tcmd;
   int retlen;
   sh_parser_state_t ps;
@@ -4114,9 +4114,11 @@ parse_comsub (qc, open, close, lenp, flags)
   if (expand_aliases)
     expand_aliases = posixly_correct != 0;
 #if defined (EXTENDED_GLOB)
-  global_extglob = extended_glob;
   if (shell_compatibility_level <= 51)
-    extended_glob = 1;
+    {
+      local_extglob = global_extglob = extended_glob;
+      extended_glob = 1;
+    }
 #endif
 
   current_token = '\n';                                /* XXX */
@@ -4131,7 +4133,8 @@ parse_comsub (qc, open, close, lenp, flags)
     }
 
 #if defined (EXTENDED_GLOB)
-  extended_glob = global_extglob;
+  if (shell_compatibility_level <= 51)
+    extended_glob = local_extglob;
 #endif
 
   parsed_command = global_command;
@@ -4259,7 +4262,7 @@ xparse_dolparen (base, string, indp, flags)
      old value will be restored by restore_parser_state(). */
   expand_aliases = 0;
 #if defined (EXTENDED_GLOB)
-  global_extglob = extended_glob;
+  global_extglob = extended_glob;              /* for reset_parser() */
 #endif
 
   token_to_read = DOLPAREN;                    /* let's trick the parser */
@@ -4597,7 +4600,7 @@ cond_term ()
 {
   WORD_DESC *op;
   COND_COM *term, *tleft, *tright;
-  int tok, lineno;
+  int tok, lineno, local_extglob;
   char *etext;
 
   /* Read a token.  It can be a left paren, a `!', a unary operator, or a
@@ -4711,11 +4714,12 @@ cond_term ()
        }
 
       /* rhs */
+      local_extglob = extended_glob;
       if (parser_state & PST_EXTPAT)
        extended_glob = 1;
       tok = read_token (READ);
       if (parser_state & PST_EXTPAT)
-       extended_glob = global_extglob;
+       extended_glob = local_extglob;
       parser_state &= ~(PST_REGEXP|PST_EXTPAT);
 
       if (tok == WORD)