From 39701204cfa0f261beb2dc056024634e4c3afd71 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 2 Aug 2017 19:44:05 +0200 Subject: hush: do not accept "if() { echo; }" function def function old new delta parse_stream 2634 2692 +58 msg_and_die_if_script - 21 +21 syntax_error_unexpected_ch 41 46 +5 syntax_error_at 14 18 +4 die_if_script 31 28 -3 setup_redirects 319 308 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/2 up/down: 88/-14) Total: 74 bytes Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-parsing/groups_and_keywords2.right | 3 +++ shell/ash_test/ash-parsing/groups_and_keywords2.tests | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 shell/ash_test/ash-parsing/groups_and_keywords2.right create mode 100755 shell/ash_test/ash-parsing/groups_and_keywords2.tests (limited to 'shell/ash_test') diff --git a/shell/ash_test/ash-parsing/groups_and_keywords2.right b/shell/ash_test/ash-parsing/groups_and_keywords2.right new file mode 100644 index 0000000..3fcbeb6 --- /dev/null +++ b/shell/ash_test/ash-parsing/groups_and_keywords2.right @@ -0,0 +1,3 @@ +./groups_and_keywords2.tests: eval: line 1: syntax error: unexpected ")" +Fail:2 +./groups_and_keywords2.tests: line 8: syntax error: unexpected ")" diff --git a/shell/ash_test/ash-parsing/groups_and_keywords2.tests b/shell/ash_test/ash-parsing/groups_and_keywords2.tests new file mode 100755 index 0000000..ab33b90 --- /dev/null +++ b/shell/ash_test/ash-parsing/groups_and_keywords2.tests @@ -0,0 +1,9 @@ +# This is an error +(eval 'if() { echo; }') +echo Fail:$? +# ^^^^^^ bash prints 1, but interactively it sets $? = 2 +# we print 2 + +# This is an error, and it aborts in script +if() { echo; } +echo Not reached -- cgit v1.1