1 From 4d2e315490b778707b3a3afdfc514d5083a97a11 Mon Sep 17 00:00:00 2001
2 From: Chet Ramey <chet.ramey@case.edu>
3 Date: Fri, 18 Jan 2019 15:12:37 -0500
4 Subject: [PATCH] Bash-5.0 patch 1: fix pathname expansion of directory names
8 bashline.c | 62 +++++++++++++++++++++++++++++++++++++++++---
9 lib/glob/glob_loop.c | 6 -----
11 3 files changed, 60 insertions(+), 10 deletions(-)
13 diff --git a/bashline.c b/bashline.c
14 index 2846aabf..75e79f1a 100644
17 @@ -231,6 +231,7 @@ static int bash_possible_variable_completions __P((int, int));
18 static int bash_complete_command __P((int, int));
19 static int bash_possible_command_completions __P((int, int));
21 +static int completion_glob_pattern __P((char *));
22 static char *glob_complete_word __P((const char *, int));
23 static int bash_glob_completion_internal __P((int));
24 static int bash_glob_complete_word __P((int, int));
25 @@ -1741,7 +1742,7 @@ bash_default_completion (text, start, end, qc, compflags)
27 /* This could be a globbing pattern, so try to expand it using pathname
29 - if (!matches && glob_pattern_p (text))
30 + if (!matches && completion_glob_pattern ((char *)text))
32 matches = rl_completion_matches (text, glob_complete_word);
33 /* A glob expression that matches more than one filename is problematic.
34 @@ -1850,7 +1851,7 @@ command_word_completion_function (hint_text, state)
35 glob_matches = (char **)NULL;
38 - globpat = glob_pattern_p (hint_text);
39 + globpat = completion_glob_pattern ((char *)hint_text);
41 /* If this is an absolute program name, do not check it against
42 aliases, reserved words, functions or builtins. We must check
43 @@ -3713,6 +3714,61 @@ bash_complete_command_internal (what_to_do)
44 return bash_specific_completion (what_to_do, command_word_completion_function);
48 +completion_glob_pattern (string)
58 + send = string + strlen (string);
60 + while (c = *string++)
80 + if (*string == '(') /*)*/
89 + /* Advance one fewer byte than an entire multibyte character to
90 + account for the auto-increment in the loop above. */
91 +#ifdef HANDLE_MULTIBYTE
93 + ADVANCE_CHAR_P (string, send - string);
96 + ADVANCE_CHAR_P (string, send - string);
102 static char *globtext;
103 static char *globorig;
105 @@ -3877,7 +3933,7 @@ bash_vi_complete (count, key)
106 t = substring (rl_line_buffer, p, rl_point);
109 - if (t && glob_pattern_p (t) == 0)
110 + if (t && completion_glob_pattern (t) == 0)
111 rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
114 diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c
115 index 5f319cc2..7d6ae211 100644
116 --- a/lib/glob/glob_loop.c
117 +++ b/lib/glob/glob_loop.c
118 @@ -54,17 +54,11 @@ INTERNAL_GLOB_PATTERN_P (pattern)
123 /* Don't let the pattern end in a backslash (GMATCH returns no match
124 if the pattern ends in a backslash anyway), but otherwise return 1,
125 since the matching engine uses backslash as an escape character
126 and it can be removed. */
127 return (*p != L('\0'));
129 - /* The pattern may not end with a backslash. */
130 - if (*p++ == L('\0'))
136 diff --git a/patchlevel.h b/patchlevel.h
137 index 1cd7c96c..40db1a32 100644
141 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
142 looks for to find the patch level (for the sccs version string). */
144 -#define PATCHLEVEL 0
145 +#define PATCHLEVEL 1
147 #endif /* _PATCHLEVEL_H_ */