Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14573

error message for missing fi is not helpful

From Manuel Reiter <manuel.reiter@dwd.de>
Newsgroups gnu.bash.bug
Subject error message for missing fi is not helpful
Date 2018-09-12 11:17 +0200
Message-ID <mailman.669.1536756475.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


++ 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
-fdebug-prefix-map=/build/bash-7fckc0/bash-4.4=.
-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:
--snip
#!/bin/bash
if true
then
   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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

error message for missing fi is not helpful Manuel Reiter <manuel.reiter@dwd.de> - 2018-09-12 11:17 +0200

csiph-web