rcolebaugh / rpms / bash

Forked from rpms/bash a year ago
Clone

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

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