summaryrefslogtreecommitdiff
path: root/pathexp.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2019-03-19 10:05:39 -0400
committerChet Ramey <chet.ramey@case.edu>2019-03-19 10:05:39 -0400
commitfcf6ae7d069a64741e9484cf219d7fe95de9e796 (patch)
tree076ef4bd5a863e6e286c9deb7b637699d7ac9c5c /pathexp.c
parentddf3f643cb9b9a2ca8e6d996c605e4332204874c (diff)
downloadbash-fcf6ae7d069a64741e9484cf219d7fe95de9e796.tar.gz
Bash-5.0 patch 3: improvements when globbing directory names containing backslashes
Diffstat (limited to 'pathexp.c')
-rw-r--r--pathexp.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/pathexp.c b/pathexp.c
index b51729a7..c1bf2d89 100644
--- a/pathexp.c
+++ b/pathexp.c
@@ -65,11 +65,11 @@ unquoted_glob_pattern_p (string)
{
register int c;
char *send;
- int open;
+ int open, bsquote;
DECLARE_MBSTATE;
- open = 0;
+ open = bsquote = 0;
send = string + strlen (string);
while (c = *string++)
@@ -100,7 +100,14 @@ unquoted_glob_pattern_p (string)
can be removed by the matching engine, so we have to run it through
globbing. */
case '\\':
- return (*string != 0);
+ if (*string != '\0' && *string != '/')
+ {
+ bsquote = 1;
+ string++;
+ continue;
+ }
+ else if (*string == 0)
+ return (0);
case CTLESC:
if (*string++ == '\0')
@@ -117,7 +124,8 @@ unquoted_glob_pattern_p (string)
ADVANCE_CHAR_P (string, send - string);
#endif
}
- return (0);
+
+ return (bsquote ? 2 : 0);
}
/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to