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 <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-08-02 19:44:05 +02:00
parent 84ea60ed65
commit 39701204cf
5 changed files with 60 additions and 17 deletions

View File

@@ -0,0 +1,3 @@
hush: syntax error: unexpected )
Fail:2
hush: syntax error: unexpected )

View File

@@ -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