aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-10 14:49:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-10 14:49:01 +0200
commit4709df0f152c477c191f83e18bfecabb2fb2c1f9 (patch)
treefa94cad09f55f5a46c8bb793637278b62f2a4b6d /shell
parentbcf56114fa7f037cea579cdc8d17ac1a5dab93a3 (diff)
downloadbusybox-w32-4709df0f152c477c191f83e18bfecabb2fb2c1f9.tar.gz
busybox-w32-4709df0f152c477c191f83e18bfecabb2fb2c1f9.tar.bz2
busybox-w32-4709df0f152c477c191f83e18bfecabb2fb2c1f9.zip
hush: fix handling of \<eof> in double-quoted strings
function old new delta encode_string 268 250 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c11
-rw-r--r--shell/hush_test/hush-parsing/bkslash_eof2.right2
-rwxr-xr-xshell/hush_test/hush-parsing/bkslash_eof2.tests4
3 files changed, 12 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 5df8d4744..98ba96e0c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4913,11 +4913,12 @@ static int encode_string(o_string *as_string,
4913 ch, ch, !!(dest->o_expflags & EXP_FLAG_ESC_GLOB_CHARS)); 4913 ch, ch, !!(dest->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
4914 if (process_bkslash && ch == '\\') { 4914 if (process_bkslash && ch == '\\') {
4915 if (next == EOF) { 4915 if (next == EOF) {
4916// TODO: what if in interactive shell a file with 4916 /* Testcase: in interactive shell a file with
4917// echo "unterminated string\<eof> 4917 * echo "unterminated string\<eof>
4918// is sourced? 4918 * is sourced.
4919 syntax_error("\\<eof>"); 4919 */
4920 xfunc_die(); 4920 syntax_error_unterm_ch('"');
4921 return 0; /* error */
4921 } 4922 }
4922 /* bash: 4923 /* bash:
4923 * "The backslash retains its special meaning [in "..."] 4924 * "The backslash retains its special meaning [in "..."]
diff --git a/shell/hush_test/hush-parsing/bkslash_eof2.right b/shell/hush_test/hush-parsing/bkslash_eof2.right
new file mode 100644
index 000000000..8be75727f
--- /dev/null
+++ b/shell/hush_test/hush-parsing/bkslash_eof2.right
@@ -0,0 +1,2 @@
1hush: syntax error: unterminated "
2One:1
diff --git a/shell/hush_test/hush-parsing/bkslash_eof2.tests b/shell/hush_test/hush-parsing/bkslash_eof2.tests
new file mode 100755
index 000000000..da1f08db6
--- /dev/null
+++ b/shell/hush_test/hush-parsing/bkslash_eof2.tests
@@ -0,0 +1,4 @@
1printf 'echo "unterminated string\\' >test.tmp.sh
2. ./test.tmp.sh
3echo One:$?
4rm -f test.tmp.sh