]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
posix change for cd; fix for command word completion where the command names contain...
authorChet Ramey <chet.ramey@case.edu>
Thu, 11 Apr 2024 01:17:29 +0000 (21:17 -0400)
committerChet Ramey <chet.ramey@case.edu>
Thu, 11 Apr 2024 01:17:29 +0000 (21:17 -0400)
CWRU/CWRU.chlog
MANIFEST
Makefile.in
bashline.c
builtins/cd.def
chat [new file with mode: 0644]
redir.c
redir.h
tests/builtins.right
variables.c

index 34cbcf6da906356ef8a57a9533bce3038bcae18d..145db0a2d79a43d50aedfc23b4ef692061fa1314 100644 (file)
@@ -9105,3 +9105,54 @@ test.c
 
 support/config.guess,support/config.sub,support/config.rpath
        - new versions, imported from gnulib
+
+                                   4/5
+                                   ---
+doc/bashref.texi
+       - update compatibility, posix mode, and bourne shell sections for
+         bash-5.3-alpha release
+
+version.c
+       - update copyright date to 2024
+
+[bash-5.3-alpha frozen]
+
+                                   4/6
+                                   ---
+builtins/cd.def
+       - cd_builtin: a null pathname argument is now an error; POSIX interp
+         1047
+
+variables.c
+       - makunbound: revert change from 7/10/2023 about preserving the export
+         attribute when unsetting a local variable in light of POSIX interp
+         1806
+
+                                   4/8
+                                   ---
+bashline.c
+       - command_word_completion_function: we don't need to perform an extra
+         comparison against what rl_filename_completion_function returns if
+         we are searching $PATH for executable completions
+       - command_word_completion_function: if a directory name from $PATH
+         contains characters that need to be quoted, quote them and set
+         rl_completion_found_quote to force rl_filename_completion_function
+         to dequote the entire pathname
+       - command_word_completion_function: since the directory name from $PATH
+         is not quoted, use the dequoted hint to construct the full pathname
+         to pass to rl_filename_completion_function (possibly after quoting it
+         From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306043
+
+                                  4/10
+                                  ----
+redir.h
+       - RX_EXPANDED: flag set when translating redirects to their final form;
+         indicates the redirection should not be expanded again
+
+redir.c
+       - do_redirection_internal: when translating a redirect into
+         r_err_and_out, set the RX_EXPANDED flag so the filename doesn't
+         get expanded again.
+         Fixes bug reported by squeaky <q7d9y9muja@liamekaens.com>
+
+         
index 1d4dee596765b7dbc9be8407ba4fdf1a4a298ecb..1514c3e921dee675044b3e2340563399287b6c39 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -254,7 +254,6 @@ lib/glob/xmbsrtowcs.c       f
 lib/glob/collsyms.h    f
 lib/glob/doc/Makefile  f
 lib/glob/doc/glob.texi f
-lib/glob/ndir.h                f
 lib/intl/Makefile.in   f
 lib/intl/VERSION       f
 lib/intl/ref-add.sin   f
@@ -667,7 +666,6 @@ CWRU/misc/sigstat.c f
 CWRU/misc/bison                f
 CWRU/misc/errlist.c    f
 CWRU/misc/hpux10-dlfcn.h       f
-CWRU/PLATFORMS         f
 CWRU/README            f
 CWRU/changelog         f
 CWRU/sh-redir-hack     f
@@ -995,6 +993,7 @@ tests/array29.sub   f
 tests/array30.sub      f
 tests/array31.sub      f
 tests/array32.sub      f
+tests/array33.sub      f
 tests/array-at-star    f
 tests/array2.right     f
 tests/assoc.tests      f
@@ -1037,6 +1036,7 @@ tests/builtins8.sub       f
 tests/builtins9.sub    f
 tests/builtins10.sub   f
 tests/builtins11.sub   f
+tests/builtins12.sub   f
 tests/source1.sub      f
 tests/source2.sub      f
 tests/source3.sub      f
@@ -1212,6 +1212,7 @@ tests/func1.sub           f
 tests/func2.sub                f
 tests/func3.sub                f
 tests/func4.sub                f
+tests/func5.sub                f
 tests/getopts.tests    f
 tests/getopts.right    f
 tests/getopts1.sub     f
index 14092c41c9a17619ad2ebda4d9866645507dd526..3b7aa0ac15d840eaaecb758be895b4f39514edd5 100644 (file)
@@ -1254,7 +1254,7 @@ subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
 subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
 subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/filecntl.h trap.h pathexp.h
 subst.o: mailcheck.h input.h $(DEFSRC)/getopt.h $(DEFSRC)/common.h
-subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h
+subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h redir.h
 subst.o: ${BASHINCDIR}/chartypes.h
 subst.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
 subst.o: ${DEFDIR}/builtext.h
index eedb09ffe30696fe611319a2b73c394cdea6efc5..9df37a0ef423d17a47c0e7580613a3c470163f06 100644 (file)
@@ -1969,6 +1969,7 @@ command_word_completion_function (const char *hint_text, int state)
   static int mapping_over, local_index, searching_path, hint_is_dir;
   static int old_glob_ignore_case, globpat;
   static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
+  static int orig_found_quote;
 #if defined (ALIAS)
   static alias_t **alias_list = (alias_t **)NULL;
 #endif /* ALIAS */
@@ -2078,7 +2079,9 @@ command_word_completion_function (const char *hint_text, int state)
 
       if (rl_completion_found_quote && rl_completion_quote_character == 0)
        dequoted_hint = bash_dequote_filename (hint, 0);
-      
+
+      orig_found_quote = rl_completion_found_quote;
+
       path = path_value ("PATH", 0);
       path_index = dot_in_path = 0;
 
@@ -2242,6 +2245,8 @@ globword:
     {
       char *current_path;
 
+      rl_completion_found_quote = orig_found_quote;
+
       /* Get the next directory from the path.  If there is none, then we
         are all done. */
       if (path == 0 || path[path_index] == 0 ||
@@ -2273,13 +2278,28 @@ globword:
        free (filename_hint);
       fnhint = filename_hint = (char *)NULL;
 
-      filename_hint = sh_makepath (current_path, hint, 0);
+      /* We can have characters that need to be quoted in either the $PATH
+        element or the dequoted filename. Since we only want to call a
+        quoting function on the entire path once, and we've already dequoted
+        the hint text we were passed (dequoted_hint), build the path using
+        the dequoted hint text and quote it if we need to. Readline will only
+        call the dequoting function if rl_completion_found_quote != 0, so
+        we have to force it. */
+
+      filename_hint = sh_makepath (current_path, dequoted_hint, 0);
       /* Need a quoted version (though it doesn't matter much in most
         cases) because rl_filename_completion_function dequotes the
         filename it gets, assuming that it's been quoted as part of
         the input line buffer. */
+#if 1
       if (strpbrk (filename_hint, "\"'\\"))
-       fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0);
+#else
+      if (strpbrk (filename_hint, rl_filename_quote_characters))
+#endif
+       {
+         fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0);
+         rl_completion_found_quote = 4;        /* just has to be non-zero */
+       }
       else
        fnhint = filename_hint;
       free (current_path);             /* XXX */
@@ -2333,10 +2353,20 @@ globword:
          if (temp)
            {
              temp++;
+#if 0
+             /* We're comparing an unquoted filename read from the directory
+                (temp, returned by rl_filename_completion_function) against
+                the possibly-quoted hint text. We should compare against
+                the dequoted hint text. */
              if (igncase == 0)
                freetemp = match = strncmp (temp, hint, hint_len) == 0;
              else
                freetemp = match = strncasecmp (temp, hint, hint_len) == 0;
+#else
+             /* Why duplicate the comparison rl_filename_completion_function
+                already performs? */
+             freetemp = match = 1;
+#endif
              if (match)
                temp = savestring (temp);
            }
index c99d67cfc0cc3f0cc355f899f814ac982fda91ba..ce2a002a42119398eb384a825f320b11567d3f0d 100644 (file)
@@ -330,13 +330,11 @@ cd_builtin (WORD_LIST *list)
       return (EX_USAGE);
     }
 #endif
-#if 0
   else if (list->word->word[0] == '\0')
     {
       builtin_error (_("null directory"));     /* POSIX cd implementation defined */
       return (EXECUTION_FAILURE);
     }
-#endif
   else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
     {
       /* This is `cd -', equivalent to `cd $OLDPWD' */
diff --git a/chat b/chat
new file mode 100644 (file)
index 0000000..c6c1276
--- /dev/null
+++ b/chat
@@ -0,0 +1,3 @@
+You are a software developer writing a widely-user open source software package. You are discussing a new feature with a user. Write an email declining the user's proposal because it is too complicated.
+
+
diff --git a/redir.c b/redir.c
index 6c2f62d2eb3c43d4fc236c252cd2ad5f448d1514..35cd6fa06d9b4a3850a2172bec7f8673d2701f73 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -829,6 +829,7 @@ do_redirection_internal (REDIRECT *redirect, int flags, char **fnp)
          sd = redirect->redirector;
          rd.filename = make_bare_word (redirectee_word);
          new_redirect = make_redirection (sd, r_err_and_out, rd, 0);
+         new_redirect->flags |= RX_EXPANDED;   /* we already expanded this */
        }
       else
        {
@@ -883,7 +884,10 @@ do_redirection_internal (REDIRECT *redirect, int flags, char **fnp)
          oflags = redirectee->flags;
          redirectee->flags |= W_NOGLOB;
        }
-      redirectee_word = redirection_expand (redirectee);
+      if ((redirect->flags & RX_EXPANDED) == 0)
+       redirectee_word = redirection_expand (redirectee);
+      else
+       redirectee_word = savestring (redirectee->word);
       if (posixly_correct && interactive_shell == 0)
        redirectee->flags = oflags;
 
diff --git a/redir.h b/redir.h
index f1378ccb39f0f9c57f2aa21a68c180d863c4b23c..31de95085141b94141669aa19236ca4d544c1881 100644 (file)
--- a/redir.h
+++ b/redir.h
@@ -31,6 +31,7 @@
 #define RX_USER                0x10
 #define RX_SAVCLEXEC   0x20    /* set close-on-exec off in restored fd even though saved on has it on */
 #define RX_SAVEFD      0x40    /* fd used to save another even if < SHELL_FD_BASE */
+#define RX_EXPANDED    0x80    /* this redirection has already been expanded */
 
 extern void redirection_error (REDIRECT *, int, char *);
 extern int do_redirections (REDIRECT *, int);
index 24b654dcc6c272aec9faec718d3d92299b41e683..e2fc4f94686956577cd0fd25f1a596c623558158 100644 (file)
@@ -413,7 +413,7 @@ SEE ALSO
     bash(1)
 
 IMPLEMENTATION
-    Copyright (C) 2022 Free Software Foundation, Inc.
+    Copyright (C) 2024 Free Software Foundation, Inc.
 
 These shell commands are defined internally.  Type `help' to see this list.
 Type `help name' to find out more about the function `name'.
index 8473e9f9df681731f9ce443062c7b6c13df1d0fc..203387f713a5d77e7d83d2636bc4bc9f4ba29f4c 100644 (file)
@@ -3982,16 +3982,10 @@ makunbound (const char *name, VAR_CONTEXT *vc)
     {
       dispose_variable_value (old_var);
 
-#if 0
       /* Reset the attributes.  Preserve the export attribute if the variable
         came from a temporary environment.  Make sure it stays local, and
         make it invisible. */ 
       old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
-#else  /* TAG:bash-5.3 look at this again */
-      /* Reset the attributes, but preserve the export attribute.
-        Make sure it stays local, and make it invisible. */ 
-      old_var->attributes = exported_p (old_var) ? att_exported : 0;
-#endif
       VSETATTR (old_var, att_local);
       VSETATTR (old_var, att_invisible);
       var_setvalue (old_var, (char *)NULL);