Merge pull request #4950 from StevenHessing/noddos
[feed/packages.git] / utils / bash / patches / 107-upstream-bash44-007.patch
1 Index: bash-4.4/bashline.c
2 ===================================================================
3 --- bash-4.4.orig/bashline.c
4 +++ bash-4.4/bashline.c
5 @@ -142,7 +142,7 @@ static int executable_completion __P((co
6 static rl_icppfunc_t *save_directory_hook __P((void));
7 static void restore_directory_hook __P((rl_icppfunc_t));
8
9 -static int directory_exists __P((const char *));
10 +static int directory_exists __P((const char *, int));
11
12 static void cleanup_expansion_error __P((void));
13 static void maybe_make_readline_line __P((char *));
14 @@ -3102,18 +3102,20 @@ restore_directory_hook (hookf)
15 rl_directory_rewrite_hook = hookf;
16 }
17
18 -/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
19 - removed, exists. */
20 +/* Check whether not DIRNAME, with any trailing slash removed, exists. If
21 + SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
22 static int
23 -directory_exists (dirname)
24 +directory_exists (dirname, should_dequote)
25 const char *dirname;
26 + int should_dequote;
27 {
28 char *new_dirname;
29 int dirlen, r;
30 struct stat sb;
31
32 - /* First, dequote the directory name */
33 - new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character);
34 + /* We save the string and chop the trailing slash because stat/lstat behave
35 + inconsistently if one is present. */
36 + new_dirname = should_dequote ? bash_dequote_filename ((char *)dirname, rl_completion_quote_character) : savestring (dirname);
37 dirlen = STRLEN (new_dirname);
38 if (new_dirname[dirlen - 1] == '/')
39 new_dirname[dirlen - 1] = '\0';
40 @@ -3145,7 +3147,7 @@ bash_filename_stat_hook (dirname)
41 else if (t = mbschr (local_dirname, '`')) /* XXX */
42 should_expand_dirname = '`';
43
44 - if (should_expand_dirname && directory_exists (local_dirname))
45 + if (should_expand_dirname && directory_exists (local_dirname, 0))
46 should_expand_dirname = 0;
47
48 if (should_expand_dirname)
49 @@ -3155,7 +3157,7 @@ bash_filename_stat_hook (dirname)
50 have to worry about restoring this setting. */
51 global_nounset = unbound_vars_is_error;
52 unbound_vars_is_error = 0;
53 - wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
54 + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
55 unbound_vars_is_error = global_nounset;
56 if (wl)
57 {
58 @@ -3244,13 +3246,13 @@ bash_directory_completion_hook (dirname)
59 should_expand_dirname = '`';
60 }
61
62 - if (should_expand_dirname && directory_exists (local_dirname))
63 + if (should_expand_dirname && directory_exists (local_dirname, 1))
64 should_expand_dirname = 0;
65
66 if (should_expand_dirname)
67 {
68 new_dirname = savestring (local_dirname);
69 - wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
70 + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
71 if (wl)
72 {
73 *dirname = string_list (wl);
74 Index: bash-4.4/patchlevel.h
75 ===================================================================
76 --- bash-4.4.orig/patchlevel.h
77 +++ bash-4.4/patchlevel.h
78 @@ -25,6 +25,6 @@
79 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
80 looks for to find the patch level (for the sccs version string). */
81
82 -#define PATCHLEVEL 6
83 +#define PATCHLEVEL 7
84
85 #endif /* _PATCHLEVEL_H_ */
86 Index: bash-4.4/subst.c
87 ===================================================================
88 --- bash-4.4.orig/subst.c
89 +++ bash-4.4/subst.c
90 @@ -9458,6 +9458,10 @@ add_twochars:
91 tword->flags |= word->flags & (W_ASSIGNARG|W_ASSIGNRHS); /* affects $@ */
92 if (word->flags & W_COMPLETE)
93 tword->flags |= W_COMPLETE; /* for command substitutions */
94 + if (word->flags & W_NOCOMSUB)
95 + tword->flags |= W_NOCOMSUB;
96 + if (word->flags & W_NOPROCSUB)
97 + tword->flags |= W_NOPROCSUB;
98
99 temp = (char *)NULL;
100