]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.2 patch 37: fix issue where comparing quoted and unquoted words to be complete...
authorChet Ramey <chet.ramey@case.edu>
Mon, 23 Sep 2024 22:19:55 +0000 (18:19 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 23 Sep 2024 22:19:55 +0000 (18:19 -0400)
lib/readline/complete.c
patchlevel.h

index e5d224ed040e71b6405846e651d694bacffb9663..2daac8c6b378005c91307fab3f9b9af18f3713a7 100644 (file)
@@ -2031,9 +2031,25 @@ rl_complete_internal (int what_to_do)
 
   text = rl_copy_text (start, end);
   matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
+  /* If TEXT contains quote characters, it will be dequoted as part of
+     generating the matches, and the matches will not contain any quote
+     characters. We need to dequote TEXT before performing the comparison.
+     Since compare_match performs the dequoting, and we only want to do it
+     once, we don't call compare_matches after dequoting TEXT; we call
+     strcmp directly. */
   /* nontrivial_lcd is set if the common prefix adds something to the word
      being completed. */
-  nontrivial_lcd = matches && compare_match (text, matches[0]) != 0;
+  if (rl_filename_completion_desired && rl_filename_quoting_desired &&
+      rl_completion_found_quote && rl_filename_dequoting_function)
+    {
+      char *t;
+      t = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
+      xfree (text);
+      text = t;
+      nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
+    }
+  else
+    nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
   if (what_to_do == '!' || what_to_do == '@')
     tlen = strlen (text);
   xfree (text);
index 0134ea1ae4de76f60aef3430d86a9b9890b57e7f..d8817d1488c1401c5dd9a8d8b79374d50c1ee825 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 36
+#define PATCHLEVEL 37
 
 #endif /* _PATCHLEVEL_H_ */