diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-07 22:24:36 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-07 22:24:36 +0200 |
commit | 33bbb27e45c7c6a0fecb40b3a5aa36aef69825f9 (patch) | |
tree | b1038e6280788218428409acf45158bf0013c5d0 /shell/ash.c | |
parent | 58a15cd9d2765e9b9bca6b71ad9713bcc3784821 (diff) | |
download | busybox-w32-33bbb27e45c7c6a0fecb40b3a5aa36aef69825f9.tar.gz busybox-w32-33bbb27e45c7c6a0fecb40b3a5aa36aef69825f9.tar.bz2 busybox-w32-33bbb27e45c7c6a0fecb40b3a5aa36aef69825f9.zip |
ash: fix another bit of var_bash4 bug
But it _still_ doesn't pass! quoted case is a tough nut to crack
function old new delta
redirect 1281 1286 +5
subevalvar 1141 1142 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index 6befe0fd3..4fbae2498 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6234,7 +6234,7 @@ parse_sub_pattern(char *arg, int varflags) | |||
6234 | unsigned char c; | 6234 | unsigned char c; |
6235 | 6235 | ||
6236 | //char *org_arg = arg; | 6236 | //char *org_arg = arg; |
6237 | //bb_error_msg("arg:'%s'", arg); | 6237 | //bb_error_msg("arg:'%s' varflags:%x", arg, varflags); |
6238 | idx = arg; | 6238 | idx = arg; |
6239 | while (1) { | 6239 | while (1) { |
6240 | c = *arg; | 6240 | c = *arg; |
@@ -6248,9 +6248,20 @@ parse_sub_pattern(char *arg, int varflags) | |||
6248 | } | 6248 | } |
6249 | } | 6249 | } |
6250 | *idx++ = c; | 6250 | *idx++ = c; |
6251 | if (!(varflags & VSQUOTE) && c == '\\' && arg[1] == '\\') | ||
6252 | arg++; /* skip both \\, not just first one */ | ||
6253 | arg++; | 6251 | arg++; |
6252 | /* | ||
6253 | * Example: v='ab\c'; echo ${v/\\b/_\\_\z_} | ||
6254 | * The result is a_\_z_c (not a\_\_z_c)! | ||
6255 | * | ||
6256 | * Enable debug prints in this function and you'll see: | ||
6257 | * ash: arg:'\\b/_\\_z_' varflags:d | ||
6258 | * ash: pattern:'\\b' repl:'_\_z_' | ||
6259 | * That is, \\b is interpreted as \\b, but \\_ as \_! | ||
6260 | * IOW: search pattern and replace string treat backslashes | ||
6261 | * differently! That is the reason why we check repl below: | ||
6262 | */ | ||
6263 | if (c == '\\' && *arg == '\\' && repl && !(varflags & VSQUOTE)) | ||
6264 | arg++; /* skip both '\', not just first one */ | ||
6254 | } | 6265 | } |
6255 | *idx = c; /* NUL */ | 6266 | *idx = c; /* NUL */ |
6256 | //bb_error_msg("pattern:'%s' repl:'%s'", org_arg, repl); | 6267 | //bb_error_msg("pattern:'%s' repl:'%s'", org_arg, repl); |