Blame SOURCES/bash-4.4-patch-7.patch

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