psss / rpms / bash

Forked from rpms/bash 6 years ago
Clone
ed01fac
From 4f747edc625815f449048579f6e65869914dd715 Mon Sep 17 00:00:00 2001
ed01fac
From: Chet Ramey <chet.ramey@case.edu>
ed01fac
Date: Fri, 20 Jan 2017 11:47:55 -0500
ed01fac
Subject: [PATCH] Bash-4.4 patch 7
ed01fac
ed01fac
---
ed01fac
 bashline.c   | 22 ++++++++++++----------
ed01fac
 patchlevel.h |  2 +-
ed01fac
 subst.c      |  4 ++++
ed01fac
 3 files changed, 17 insertions(+), 11 deletions(-)
ed01fac
ed01fac
diff --git a/bashline.c b/bashline.c
ed01fac
index f4fe9f1..0275844 100644
ed01fac
--- a/bashline.c
ed01fac
+++ b/bashline.c
ed01fac
@@ -142,7 +142,7 @@ static int executable_completion __P((const char *, int));
ed01fac
 static rl_icppfunc_t *save_directory_hook __P((void));
ed01fac
 static void restore_directory_hook __P((rl_icppfunc_t));
ed01fac
 
ed01fac
-static int directory_exists __P((const char *));
ed01fac
+static int directory_exists __P((const char *, int));
ed01fac
 
ed01fac
 static void cleanup_expansion_error __P((void));
ed01fac
 static void maybe_make_readline_line __P((char *));
ed01fac
@@ -3102,18 +3102,20 @@ restore_directory_hook (hookf)
ed01fac
     rl_directory_rewrite_hook = hookf;
ed01fac
 }
ed01fac
 
ed01fac
-/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
ed01fac
-   removed, exists. */
ed01fac
+/* Check whether not DIRNAME, with any trailing slash removed, exists.  If
ed01fac
+   SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
ed01fac
 static int
ed01fac
-directory_exists (dirname)
ed01fac
+directory_exists (dirname, should_dequote)
ed01fac
      const char *dirname;
ed01fac
+     int should_dequote;
ed01fac
 {
ed01fac
   char *new_dirname;
ed01fac
   int dirlen, r;
ed01fac
   struct stat sb;
ed01fac
 
ed01fac
-  /* First, dequote the directory name */
ed01fac
-  new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character);
ed01fac
+  /* We save the string and chop the trailing slash because stat/lstat behave
ed01fac
+     inconsistently if one is present. */
ed01fac
+  new_dirname = should_dequote ? bash_dequote_filename ((char *)dirname, rl_completion_quote_character) : savestring (dirname);
ed01fac
   dirlen = STRLEN (new_dirname);
ed01fac
   if (new_dirname[dirlen - 1] == '/')
ed01fac
     new_dirname[dirlen - 1] = '\0';
ed01fac
@@ -3145,7 +3147,7 @@ bash_filename_stat_hook (dirname)
ed01fac
   else if (t = mbschr (local_dirname, '`'))	/* XXX */
ed01fac
     should_expand_dirname = '`';
ed01fac
 
ed01fac
-  if (should_expand_dirname && directory_exists (local_dirname))
ed01fac
+  if (should_expand_dirname && directory_exists (local_dirname, 0))
ed01fac
     should_expand_dirname = 0;
ed01fac
   
ed01fac
   if (should_expand_dirname)  
ed01fac
@@ -3155,7 +3157,7 @@ bash_filename_stat_hook (dirname)
ed01fac
 	 have to worry about restoring this setting. */
ed01fac
       global_nounset = unbound_vars_is_error;
ed01fac
       unbound_vars_is_error = 0;
ed01fac
-      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE);	/* does the right thing */
ed01fac
+      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE);	/* does the right thing */
ed01fac
       unbound_vars_is_error = global_nounset;
ed01fac
       if (wl)
ed01fac
 	{
ed01fac
@@ -3244,13 +3246,13 @@ bash_directory_completion_hook (dirname)
ed01fac
 	should_expand_dirname = '`';
ed01fac
     }
ed01fac
 
ed01fac
-  if (should_expand_dirname && directory_exists (local_dirname))
ed01fac
+  if (should_expand_dirname && directory_exists (local_dirname, 1))
ed01fac
     should_expand_dirname = 0;
ed01fac
 
ed01fac
   if (should_expand_dirname)  
ed01fac
     {
ed01fac
       new_dirname = savestring (local_dirname);
ed01fac
-      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE);	/* does the right thing */
ed01fac
+      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE);	/* does the right thing */
ed01fac
       if (wl)
ed01fac
 	{
ed01fac
 	  *dirname = string_list (wl);
ed01fac
diff --git a/patchlevel.h b/patchlevel.h
ed01fac
index 14bff9f..deb9c5b 100644
ed01fac
--- a/patchlevel.h
ed01fac
+++ b/patchlevel.h
ed01fac
@@ -25,6 +25,6 @@
ed01fac
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
ed01fac
    looks for to find the patch level (for the sccs version string). */
ed01fac
 
ed01fac
-#define PATCHLEVEL 6
ed01fac
+#define PATCHLEVEL 7
ed01fac
 
ed01fac
 #endif /* _PATCHLEVEL_H_ */
ed01fac
diff --git a/subst.c b/subst.c
ed01fac
index 298187d..027a13e 100644
ed01fac
--- a/subst.c
ed01fac
+++ b/subst.c
ed01fac
@@ -9458,6 +9458,10 @@ add_twochars:
ed01fac
 		tword->flags |= word->flags & (W_ASSIGNARG|W_ASSIGNRHS);	/* affects $@ */
ed01fac
 	      if (word->flags & W_COMPLETE)
ed01fac
 		tword->flags |= W_COMPLETE;	/* for command substitutions */
ed01fac
+	      if (word->flags & W_NOCOMSUB)
ed01fac
+		tword->flags |= W_NOCOMSUB;
ed01fac
+	      if (word->flags & W_NOPROCSUB)
ed01fac
+		tword->flags |= W_NOPROCSUB;
ed01fac
 
ed01fac
 	      temp = (char *)NULL;
ed01fac
 
ed01fac
-- 
ed01fac
2.9.3
ed01fac