Path: csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.ripco.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Chet Ramey Newsgroups: gnu.bash.bug Subject: Re: Bash does not exit on non-interactive "Bad substitution" errors Date: Fri, 7 Aug 2015 14:30:27 -0400 Lines: 34 Approved: bug-bash@gnu.org Message-ID: References: <87vbcvi7de.fsf@gmail.com> Reply-To: chet.ramey@case.edu NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1438972242 13862 208.118.235.17 (7 Aug 2015 18:30:42 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu To: Christian Neukirchen , bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: <87vbcvi7de.fsf@gmail.com> X-Junkmail-Status: score=10/50, host=mpv5.cwru.edu X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 129.22.105.36 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11302 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 chet@case.edu http://cnswww.cns.cwru.edu/~chet/