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


Groups > gnu.bash.bug > #11292

Bash does not exit on non-interactive "Bad substitution" errors

From Christian Neukirchen <chneukirchen@gmail.com>
Newsgroups gnu.bash.bug
Subject Bash does not exit on non-interactive "Bad substitution" errors
Date 2015-08-04 14:08 +0200
Message-ID <mailman.7814.1438693340.904.bug-bash@gnu.org> (permalink)

Show all headers | View raw


Hi,

I noticed that the following script keeps executing (and outputs
"oops") in Bash 4.3.39(1)-release and 2.05b.13(1)-release, in
difference to dash-0.5.8, mksh-R51, busybox sh v1.23.2, ksh-2012.08.01,
and zsh-5.0.8:

echo ${x!y}
echo oops

According to IEEE Std 1003.1, 2.8.1 Consequences of Shell Errors
"An expansion error is one that occurs when the shell expansions
defined in wordexp are carried out (for example, "${x!y}", because '!'
is not a valid operator)" and should result in "Shall exit" from a
non-interactive script.

In particular, this also happens when the expansion error occurs in a
line consisting of an "exec"-statement, where evaluation usually *never*
continues (e.g. bash correctly exits when the command is not found).

I think to avoid further damage due to badly set variables, bash
should exit in this case as well.

Thanks,
-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org

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


Thread

Bash does not exit on non-interactive "Bad substitution" errors Christian Neukirchen <chneukirchen@gmail.com> - 2015-08-04 14:08 +0200

csiph-web