aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f6190c3e2..42c91257e 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6992,10 +6992,11 @@ expmeta(char *expdir, char *enddir, char *name)
struct dirent *dp;
int atend;
int matchdot;
+ int esc;
metaflag = 0;
start = name;
- for (p = name; *p; p++) {
+ for (p = name; esc = 0, *p; p += esc + 1) {
if (*p == '*' || *p == '?')
metaflag = 1;
else if (*p == '[') {
@@ -7012,15 +7013,16 @@ expmeta(char *expdir, char *enddir, char *name)
break;
}
}
- } else if (*p == '\\')
- p++;
- else if (*p == '/') {
- if (metaflag)
- goto out;
- start = p + 1;
+ } else {
+ if (*p == '\\')
+ esc++;
+ if (p[esc] == '/') {
+ if (metaflag)
+ break;
+ start = p + esc + 1;
+ }
}
}
- out:
if (metaflag == 0) { /* we've reached the end of the file name */
if (enddir != expdir)
metaflag++;
@@ -7060,7 +7062,8 @@ expmeta(char *expdir, char *enddir, char *name)
atend = 1;
} else {
atend = 0;
- *endname++ = '\0';
+ *endname = '\0';
+ endname += esc + 1;
}
matchdot = 0;
p = start;
@@ -7085,7 +7088,7 @@ expmeta(char *expdir, char *enddir, char *name)
}
closedir(dirp);
if (!atend)
- endname[-1] = '/';
+ endname[-esc - 1] = esc ? '\\' : '/';
}
static struct strlist *