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>
This commit is contained in:
parent
bcf56114fa
commit
4709df0f15
11
shell/hush.c
11
shell/hush.c
@ -4913,11 +4913,12 @@ static int encode_string(o_string *as_string,
|
|||||||
ch, ch, !!(dest->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
|
ch, ch, !!(dest->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
|
||||||
if (process_bkslash && ch == '\\') {
|
if (process_bkslash && ch == '\\') {
|
||||||
if (next == EOF) {
|
if (next == EOF) {
|
||||||
// TODO: what if in interactive shell a file with
|
/* Testcase: in interactive shell a file with
|
||||||
// echo "unterminated string\<eof>
|
* echo "unterminated string\<eof>
|
||||||
// is sourced?
|
* is sourced.
|
||||||
syntax_error("\\<eof>");
|
*/
|
||||||
xfunc_die();
|
syntax_error_unterm_ch('"');
|
||||||
|
return 0; /* error */
|
||||||
}
|
}
|
||||||
/* bash:
|
/* bash:
|
||||||
* "The backslash retains its special meaning [in "..."]
|
* "The backslash retains its special meaning [in "..."]
|
||||||
|
2
shell/hush_test/hush-parsing/bkslash_eof2.right
Normal file
2
shell/hush_test/hush-parsing/bkslash_eof2.right
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
hush: syntax error: unterminated "
|
||||||
|
One:1
|
4
shell/hush_test/hush-parsing/bkslash_eof2.tests
Executable file
4
shell/hush_test/hush-parsing/bkslash_eof2.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
printf 'echo "unterminated string\\' >test.tmp.sh
|
||||||
|
. ./test.tmp.sh
|
||||||
|
echo One:$?
|
||||||
|
rm -f test.tmp.sh
|
Loading…
Reference in New Issue
Block a user