bug-bash
[Top][All Lists]
Advanced

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

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


From: Christian Neukirchen
Subject: Bash does not exit on non-interactive "Bad substitution" errors
Date: Tue, 04 Aug 2015 14:08:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

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  <address@hidden>  http://chneukirchen.org



reply via email to

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