[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

error message for missing fi is not helpful

From: Manuel Reiter
Subject: error message for missing fi is not helpful
Date: Wed, 12 Sep 2018 11:17:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

++ Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie
-Wno-parentheses -Wno-format-security
uname output: Linux eeyore 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3
(2017-12-03) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

++ Description:

When an if statement is not terminated by a fi, bash's error message is
not helpful in locating the problem.

This was mentioned in
http://lists.gnu.org/archive/html/bug-bash/2008-06/msg00105.html but
never replied to.

I don't know whether bash allows an if statement to be terminated by EOF
(as it does for a here document which was the original subject of the
cited post) but even if it does, a warning message might be helpful.

This applies to case not being terminated by esac (and possibly other
commands) as well.

++ Repeat-By:

+ run the following script in bash:
if true
  exit 0
# fi missing

exit 1
-- snip

+ expected output:

./test.bash: line 2: syntax error: if without corresponding fi

or at least

./test.bash: line 2: warning: if without corresponding fi

+ actual output:

./test.bash: line 8: syntax error: unexpected end of file

reply via email to

[Prev in Thread] Current Thread [Next in Thread]