summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash_test/ash-parsing/nodone1.right1
-rwxr-xr-xshell/ash_test/ash-parsing/nodone1.tests1
-rw-r--r--shell/ash_test/ash-parsing/nodone2.right1
-rwxr-xr-xshell/ash_test/ash-parsing/nodone2.tests3
-rw-r--r--shell/hush.c11
-rw-r--r--shell/hush_test/hush-parsing/nodone1.right1
-rwxr-xr-xshell/hush_test/hush-parsing/nodone1.tests1
-rw-r--r--shell/hush_test/hush-parsing/nodone2.right1
-rwxr-xr-xshell/hush_test/hush-parsing/nodone2.tests3
9 files changed, 22 insertions, 1 deletions
diff --git a/shell/ash_test/ash-parsing/nodone1.right b/shell/ash_test/ash-parsing/nodone1.right
new file mode 100644
index 0000000..0150cca
--- /dev/null
+++ b/shell/ash_test/ash-parsing/nodone1.right
@@ -0,0 +1 @@
+./nodone1.tests: line 2: syntax error: unexpected end of file (expecting "done")
diff --git a/shell/ash_test/ash-parsing/nodone1.tests b/shell/ash_test/ash-parsing/nodone1.tests
new file mode 100755
index 0000000..de286c5
--- /dev/null
+++ b/shell/ash_test/ash-parsing/nodone1.tests
@@ -0,0 +1 @@
+for i; do :
diff --git a/shell/ash_test/ash-parsing/nodone2.right b/shell/ash_test/ash-parsing/nodone2.right
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/shell/ash_test/ash-parsing/nodone2.right
@@ -0,0 +1 @@
+1
diff --git a/shell/ash_test/ash-parsing/nodone2.tests b/shell/ash_test/ash-parsing/nodone2.tests
new file mode 100755
index 0000000..69537b3
--- /dev/null
+++ b/shell/ash_test/ash-parsing/nodone2.tests
@@ -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 \ No newline at end of file
diff --git a/shell/hush.c b/shell/hush.c
index 0c91008..3e6a13b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -5497,6 +5497,15 @@ static struct pipe *parse_stream(char **pstring,
}
o_free_and_set_NULL(&ctx.word);
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;
/* If we got nothing... */
/* (this makes bare "&" cmd a no-op.
@@ -5519,7 +5528,7 @@ static struct pipe *parse_stream(char **pstring,
// *heredoc_cnt_ptr = heredoc_cnt;
debug_leave();
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;
}
diff --git a/shell/hush_test/hush-parsing/nodone1.right b/shell/hush_test/hush-parsing/nodone1.right
new file mode 100644
index 0000000..3dc1bcf
--- /dev/null
+++ b/shell/hush_test/hush-parsing/nodone1.right
@@ -0,0 +1 @@
+hush: syntax error: unterminated compound statement
diff --git a/shell/hush_test/hush-parsing/nodone1.tests b/shell/hush_test/hush-parsing/nodone1.tests
new file mode 100755
index 0000000..de286c5
--- /dev/null
+++ b/shell/hush_test/hush-parsing/nodone1.tests
@@ -0,0 +1 @@
+for i; do :
diff --git a/shell/hush_test/hush-parsing/nodone2.right b/shell/hush_test/hush-parsing/nodone2.right
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/shell/hush_test/hush-parsing/nodone2.right
@@ -0,0 +1 @@
+1
diff --git a/shell/hush_test/hush-parsing/nodone2.tests b/shell/hush_test/hush-parsing/nodone2.tests
new file mode 100755
index 0000000..69537b3
--- /dev/null
+++ b/shell/hush_test/hush-parsing/nodone2.tests
@@ -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 \ No newline at end of file