mirror of https://github.com/mirror/busybox.git
hush: detect when terminating "done"/"fi" is missing
function old new delta parse_stream 2271 2292 +21 .rodata 105408 105427 +19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>master
parent
2639f3bc72
commit
758b21402a
|
@ -0,0 +1 @@
|
||||||
|
./nodone1.tests: line 2: syntax error: unexpected end of file (expecting "done")
|
|
@ -0,0 +1 @@
|
||||||
|
for i; do :
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,3 @@
|
||||||
|
for i in 1; do echo $i
|
||||||
|
# the next line has no EOL. It still must count as "done" keyword:
|
||||||
|
done
|
11
shell/hush.c
11
shell/hush.c
|
@ -5497,6 +5497,15 @@ static struct pipe *parse_stream(char **pstring,
|
||||||
}
|
}
|
||||||
o_free_and_set_NULL(&ctx.word);
|
o_free_and_set_NULL(&ctx.word);
|
||||||
done_pipe(&ctx, PIPE_SEQ);
|
done_pipe(&ctx, PIPE_SEQ);
|
||||||
|
|
||||||
|
/* Do we sit inside of any if's, loops or case's? */
|
||||||
|
if (HAS_KEYWORDS
|
||||||
|
IF_HAS_KEYWORDS(&& (ctx.ctx_res_w != RES_NONE || ctx.old_flag != 0))
|
||||||
|
) {
|
||||||
|
syntax_error_unterm_str("compound statement");
|
||||||
|
goto parse_error_exitcode1;
|
||||||
|
}
|
||||||
|
|
||||||
pi = ctx.list_head;
|
pi = ctx.list_head;
|
||||||
/* If we got nothing... */
|
/* If we got nothing... */
|
||||||
/* (this makes bare "&" cmd a no-op.
|
/* (this makes bare "&" cmd a no-op.
|
||||||
|
@ -5519,7 +5528,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||||
// *heredoc_cnt_ptr = heredoc_cnt;
|
// *heredoc_cnt_ptr = heredoc_cnt;
|
||||||
debug_leave();
|
debug_leave();
|
||||||
debug_printf_heredoc("parse_stream return heredoc_cnt:%d\n", heredoc_cnt);
|
debug_printf_heredoc("parse_stream return heredoc_cnt:%d\n", heredoc_cnt);
|
||||||
debug_printf_parse("parse_stream return %p\n", pi);
|
debug_printf_parse("parse_stream return %p: EOF\n", pi);
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
hush: syntax error: unterminated compound statement
|
|
@ -0,0 +1 @@
|
||||||
|
for i; do :
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,3 @@
|
||||||
|
for i in 1; do echo $i
|
||||||
|
# the next line has no EOL. It still must count as "done" keyword:
|
||||||
|
done
|
Loading…
Reference in New Issue