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


Groups > gnu.bash.bug > #11292 > unrolled thread

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

Started byChristian Neukirchen <chneukirchen@gmail.com>
First post2015-08-04 14:08 +0200
Last post2015-08-04 14:08 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

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

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

FromChristian Neukirchen <chneukirchen@gmail.com>
Date2015-08-04 14:08 +0200
SubjectBash does not exit on non-interactive "Bad substitution" errors
Message-ID<mailman.7814.1438693340.904.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web