On Thu, May 15, 2008 at 02:26:02PM +0000, Romain Tartière wrote: > > I can't figure out why '*/FILE' and '*"/FILE"' are not expanded the same > way... This is a bug in dash. The following patch should fix the problem, provided that Ubuntu hasn't built dash with glob(3) enabled because glob(3) has a similar bug and that needs to be fixed in glibc. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- diff --git a/ChangeLog b/ChangeLog index 2f65e03..bf9dd4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-05-19 Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> + + * Fixed non-leading slash treatment in expmeta. + 2008-05-07 Gerrit Pape <pape@xxxxxxxxxxx> * Fixed lexical error in arithmetic expansion of & and |. diff --git a/src/expand.c b/src/expand.c index 2c52781..e4c4c8b 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1269,10 +1269,11 @@ expmeta(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 == '[') { @@ -1291,11 +1292,11 @@ expmeta(char *enddir, char *name) } } else { if (*p == '\\') - p++; - if (*p == '/') { + esc++; + if (p[esc] == '/') { if (metaflag) break; - start = p + 1; + start = p + esc + 1; } } } @@ -1337,7 +1338,8 @@ expmeta(char *enddir, char *name) atend = 1; } else { atend = 0; - *endname++ = '\0'; + *endname = '\0'; + endname += esc + 1; } matchdot = 0; p = start; @@ -1363,7 +1365,7 @@ expmeta(char *enddir, char *name) } closedir(dirp); if (! atend) - endname[-1] = '/'; + endname[-esc - 1] = esc ? '\\' : '/'; } #endif /* HAVE_GLOB */ -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html