rcolebaugh / rpms / bash

Forked from rpms/bash 2 years ago
Clone

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

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