diff options
author | Denis Vlasenko | 2008-04-14 01:59:53 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-04-14 01:59:53 +0000 |
commit | c7131c3e58c2cef17263d03ac542f7fbea1ce2db (patch) | |
tree | df7aa8e9b9d20752440de4b33f60fd716cf2b717 /shell/ash.c | |
parent | b15ebe46fc97d7a870a54249b617904bb4a5fb92 (diff) | |
download | busybox-c7131c3e58c2cef17263d03ac542f7fbea1ce2db.zip busybox-c7131c3e58c2cef17263d03ac542f7fbea1ce2db.tar.gz |
ash: fix breakage introduced in rev 21481.
Fixes ash-vars/var_posix1.tests testsuite entry.
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/shell/ash.c b/shell/ash.c index 409d084..8024138 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5691,13 +5691,39 @@ static char * scanleft(char *startp, char *rmesc, char *rmescend ATTRIBUTE_UNUSED, char *str, int quotes, int zero) { - char *loc, *loc2, *full; +// This commented out code was added by James Simmons <jsimmons@infradead.org> +// as part of a larger change when he added support for ${var/a/b}. +// However, it broke # and % operators: +// +//var=ababcdcd +// ok bad +//echo ${var#ab} abcdcd abcdcd +//echo ${var##ab} abcdcd abcdcd +//echo ${var#a*b} abcdcd ababcdcd (!) +//echo ${var##a*b} cdcd cdcd +//echo ${var#?} babcdcd ababcdcd (!) +//echo ${var##?} babcdcd babcdcd +//echo ${var#*} ababcdcd babcdcd (!) +//echo ${var##*} +//echo ${var%cd} ababcd ababcd +//echo ${var%%cd} ababcd abab (!) +//echo ${var%c*d} ababcd ababcd +//echo ${var%%c*d} abab ababcdcd (!) +//echo ${var%?} ababcdc ababcdc +//echo ${var%%?} ababcdc ababcdcd (!) +//echo ${var%*} ababcdcd ababcdcd +//echo ${var%%*} +// +// Commenting it back out helped. Remove it completely if it really +// is not needed. + + char *loc, *loc2; //, *full; char c; loc = startp; loc2 = rmesc; do { - int match = strlen(str); + int match; // = strlen(str); const char *s = loc2; c = *loc2; @@ -5705,23 +5731,24 @@ scanleft(char *startp, char *rmesc, char *rmescend ATTRIBUTE_UNUSED, char *str, *loc2 = '\0'; s = rmesc; } - - // chop off end if its '*' - full = strrchr(str, '*'); - if (full && full != str) - match--; - - // If str starts with '*' replace with s. - if ((*str == '*') && strlen(s) >= match) { - full = xstrdup(s); - strncpy(full+strlen(s)-match+1, str+1, match-1); - } else - full = xstrndup(str, match); - match = strncmp(s, full, strlen(full)); - free(full); - + match = pmatch(str, s); // this line was deleted + +// // chop off end if its '*' +// full = strrchr(str, '*'); +// if (full && full != str) +// match--; +// +// // If str starts with '*' replace with s. +// if ((*str == '*') && strlen(s) >= match) { +// full = xstrdup(s); +// strncpy(full+strlen(s)-match+1, str+1, match-1); +// } else +// full = xstrndup(str, match); +// match = strncmp(s, full, strlen(full)); +// free(full); +// *loc2 = c; - if (!match) + if (match) // if (!match) return loc; if (quotes && *loc == CTLESC) loc++; |