bug-bash
[Top][All Lists]
Advanced

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

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


From: Chet Ramey
Subject: Re: Bash does not exit on non-interactive "Bad substitution" errors
Date: Fri, 7 Aug 2015 14:30:27 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1

On 8/4/15 8:08 AM, Christian Neukirchen wrote:
> 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

Yes, you're correct.  Bash has always treated many word expansion errors
as causing the current command to fail but not fatal errors, even when
the shell is not interactive.

> 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.

Yes.  I'm going to do two things with this in bash-4.4.  If you set the
shell compatibility level to 43, such constructs will continue to generate
non-fatal expansion errors.  Otherwise, when in Posix mode, they will
cause a  non-interactive shell to exit.

A future version of the shell will change to exit even in non-Posix mode.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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