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

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail
From Christian Neukirchen <chneukirchen@gmail.com>
Newsgroups gnu.bash.bug
Subject Bash does not exit on non-interactive "Bad substitution" errors
Date Tue, 04 Aug 2015 14:08:13 +0200
Lines 27
Approved bug-bash@gnu.org
Message-ID <mailman.7814.1438693340.904.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain
X-Trace usenet.stanford.edu 1438693340 23165 208.118.235.17 (4 Aug 2015 13:02:20 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=fQZYcJJYGCq6PGfY3c/mDzs6qFdFj82xOruUirxZT3U=; b=vfovPraSfKd2/aUONGTGrffX8tslnCfTPDDKDoqdHl8UrSyARqVg3QEGWd0am8O2oA BaUfMbJJAlkKlE/e4q87MW2sgTrMcqcUhRkoulPaDc5F+H0FBWnt5s2F3Q8MWkziAWAg RbhD5C4L9V6jG2mkaaoNz4sqNhDxugHQiYHlLieXbhBN6zoOwzqFegHupYyL/WzfU7D+ zuq5ruRJ57hLm/RjuOckocoQR1VYFkiGeHb4ihB/sjtB5FJ9jxWMtPhyUCw3Tx7mc4QW yOa6/+USubnID5tK5dw68qtlpQKWLwOqyREjSQI75hFPOSc5IG0motatyRJ0D8Znpw/v j49g==
X-Received by 10.195.11.74 with SMTP id eg10mr7169780wjd.33.1438690094530; Tue, 04 Aug 2015 05:08:14 -0700 (PDT)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
X-detected-operating-system by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value).
X-Received-From 2a00:1450:400c:c05::22e
X-Mailman-Approved-At Tue, 04 Aug 2015 09:02:19 -0400
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11292

Show key headers only | 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