7 Bug-Reported-by: Jens Heyens <jens.heyens@cispa.saarland>
9 Bug-Reference-URL: https://savannah.gnu.org/support/?109224
13 When performing filename completion, bash dequotes the directory name being
14 completed, which can result in match failures and potential unwanted
17 Patch (apply with `patch -p0'):
19 *** ../bash-4.4-patched/bashline.c 2016-08-05 21:44:05.000000000 -0400
20 --- bashline.c 2017-01-19 13:15:51.000000000 -0500
23 static void restore_directory_hook __P((rl_icppfunc_t));
25 ! static int directory_exists __P((const char *));
27 static void cleanup_expansion_error __P((void));
29 static void restore_directory_hook __P((rl_icppfunc_t));
31 ! static int directory_exists __P((const char *, int));
33 static void cleanup_expansion_error __P((void));
38 ! /* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
41 ! directory_exists (dirname)
48 ! /* Check whether not DIRNAME, with any trailing slash removed, exists. If
49 ! SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
51 ! directory_exists (dirname, should_dequote)
60 ! /* First, dequote the directory name */
61 ! new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character);
62 dirlen = STRLEN (new_dirname);
63 if (new_dirname[dirlen - 1] == '/')
67 ! /* We save the string and chop the trailing slash because stat/lstat behave
68 ! inconsistently if one is present. */
69 ! new_dirname = should_dequote ? bash_dequote_filename ((char *)dirname, rl_completion_quote_character) : savestring (dirname);
70 dirlen = STRLEN (new_dirname);
71 if (new_dirname[dirlen - 1] == '/')
74 should_expand_dirname = '`';
76 ! if (should_expand_dirname && directory_exists (local_dirname))
77 should_expand_dirname = 0;
80 should_expand_dirname = '`';
82 ! if (should_expand_dirname && directory_exists (local_dirname, 0))
83 should_expand_dirname = 0;
87 global_nounset = unbound_vars_is_error;
88 unbound_vars_is_error = 0;
89 ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
90 unbound_vars_is_error = global_nounset;
93 global_nounset = unbound_vars_is_error;
94 unbound_vars_is_error = 0;
95 ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
96 unbound_vars_is_error = global_nounset;
102 ! if (should_expand_dirname && directory_exists (local_dirname))
103 should_expand_dirname = 0;
108 ! if (should_expand_dirname && directory_exists (local_dirname, 1))
109 should_expand_dirname = 0;
114 new_dirname = savestring (local_dirname);
115 ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
120 new_dirname = savestring (local_dirname);
121 ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
124 *** ../bash-4.4/subst.c 2016-08-30 16:46:38.000000000 -0400
125 --- subst.c 2017-01-19 07:09:57.000000000 -0500
129 if (word->flags & W_COMPLETE)
130 tword->flags |= W_COMPLETE; /* for command substitutions */
131 + if (word->flags & W_NOCOMSUB)
132 + tword->flags |= W_NOCOMSUB;
133 + if (word->flags & W_NOPROCSUB)
134 + tword->flags |= W_NOPROCSUB;
137 *** ../bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
138 --- patchlevel.h 2016-10-01 11:01:28.000000000 -0400
141 looks for to find the patch level (for the sccs version string). */
143 ! #define PATCHLEVEL 6
145 #endif /* _PATCHLEVEL_H_ */
147 looks for to find the patch level (for the sccs version string). */
149 ! #define PATCHLEVEL 7
151 #endif /* _PATCHLEVEL_H_ */