aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-10 14:40:23 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-10 14:40:23 +0200
commitbcf56114fa7f037cea579cdc8d17ac1a5dab93a3 (patch)
tree2bd982c3253f2ca83a84ecc2c4632f20c620a9ad /shell
parent92a930b4e8dce1b8d884a83d7f38bb139ab8317f (diff)
downloadbusybox-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')
-rw-r--r--shell/hush.c14
-rw-r--r--shell/hush_test/hush-parsing/bkslash_eof1.right1
-rwxr-xr-xshell/hush_test/hush-parsing/bkslash_eof1.tests1
3 files changed, 11 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);
diff --git a/shell/hush_test/hush-parsing/bkslash_eof1.right b/shell/hush_test/hush-parsing/bkslash_eof1.right
new file mode 100644
index 000000000..9766475a4
--- /dev/null
+++ b/shell/hush_test/hush-parsing/bkslash_eof1.right
@@ -0,0 +1 @@
ok
diff --git a/shell/hush_test/hush-parsing/bkslash_eof1.tests b/shell/hush_test/hush-parsing/bkslash_eof1.tests
new file mode 100755
index 000000000..97629cb13
--- /dev/null
+++ b/shell/hush_test/hush-parsing/bkslash_eof1.tests
@@ -0,0 +1 @@
eval 'echo ok\'