diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-10 14:40:23 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-10 14:40:23 +0200 |
commit | bcf56114fa7f037cea579cdc8d17ac1a5dab93a3 (patch) | |
tree | 2bd982c3253f2ca83a84ecc2c4632f20c620a9ad /shell/hush.c | |
parent | 92a930b4e8dce1b8d884a83d7f38bb139ab8317f (diff) | |
download | busybox-w32-bcf56114fa7f037cea579cdc8d17ac1a5dab93a3.tar.gz busybox-w32-bcf56114fa7f037cea579cdc8d17ac1a5dab93a3.tar.bz2 busybox-w32-bcf56114fa7f037cea579cdc8d17ac1a5dab93a3.zip |
hush: fix eval 'echo ok\'
function old new delta
parse_stream 2762 2753 -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c index 6cd85cc4d..5df8d4744 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -5379,15 +5379,19 @@ static struct pipe *parse_stream(char **pstring, | |||
5379 | continue; /* get next char */ | 5379 | continue; /* get next char */ |
5380 | case '\\': | 5380 | case '\\': |
5381 | /*nommu_addchr(&ctx.as_string, '\\'); - already done */ | 5381 | /*nommu_addchr(&ctx.as_string, '\\'); - already done */ |
5382 | o_addchr(&ctx.word, '\\'); | ||
5383 | ch = i_getch(input); | 5382 | ch = i_getch(input); |
5384 | if (ch == EOF) { | 5383 | if (ch == EOF) { |
5385 | //TODO: in ". FILE" containing "cmd\" (no newline) bash ignores last "\" | 5384 | /* Ignore this '\'. Testcase: eval 'echo Ok\' */ |
5386 | syntax_error("\\<eof>"); | 5385 | #if !BB_MMU |
5387 | xfunc_die(); | 5386 | /* Remove trailing '\' from ctx.as_string */ |
5387 | ctx.as_string.data[--ctx.as_string.length] = '\0'; | ||
5388 | #endif | ||
5389 | continue; /* get next char */ | ||
5388 | } | 5390 | } |
5391 | o_addchr(&ctx.word, '\\'); | ||
5389 | /* Example: echo Hello \2>file | 5392 | /* Example: echo Hello \2>file |
5390 | * we need to know that word 2 is quoted */ | 5393 | * we need to know that word 2 is quoted |
5394 | */ | ||
5391 | ctx.word.has_quoted_part = 1; | 5395 | ctx.word.has_quoted_part = 1; |
5392 | nommu_addchr(&ctx.as_string, ch); | 5396 | nommu_addchr(&ctx.as_string, ch); |
5393 | o_addchr(&ctx.word, ch); | 5397 | o_addchr(&ctx.word, ch); |