Article View: gnu.bash.bug
Article #494Re: parameter test
From: Chet Ramey
Date: Thu, 24 Aug 1989 00:50
Date: Thu, 24 Aug 1989 00:50
50 lines
2014 bytes
2014 bytes
In article <8908231654.AA10031@dash.mitre.org> barratt@DASH.MITRE.ORG (Jeff Barratt) writes:
>Bash Version 1.02
>Problem:
> Improper action from parameter test. A parameter that doesn't exist
>causes exit from the shell, rather than executing the "action".
> Example on machine "dash". Parameter ZIP does not exist:
>
>dash$ : ${ZIP:?"No ZIP here"}
> shell exits
Here is what happens for me with bash:
cwns1$ echo $SHLVL
2
cwns1$ bash
cwns1$ echo $SHLVL
3
cwns1$ ${ZIP:?"No ZIP here"}
No ZIP here
cwns1$ echo $SHLVL
2
This is what happens with a S5r2 sh:
cwns1$ echo ${Z:?no}
Z: no
cwns1$ echo ${Z:?}
Z: parameter null or not set
cwns1$
This is what the spec mandates, and this behavior has been in the Bourne
shell since its creation (i.e. 7th Edition). Quoting from a random System
5 release 2+ man page (this happens to be from Ultrix 3.0 sh5):
${parameter:?word}
If parameter is set and is non-null, substitute its
value; otherwise, print word and exit from the shell.
If word is omitted, the message ``parameter null or not
set'' is printed.
The wording is essentially the same for the 4.3BSD sh, which means it was in
the 7th Edition sh.
I think it's brain-dead, but then I wasn't on the committee...
Chet Ramey
Chet Ramey "We are preparing to think about contemplating
Network Services Group, CWRU preliminary work on plans to develop a
chet@cwjcc.INS.CWRU.Edu schedule for producing the 10th Edition of
the Unix Programmers Manual." -- Andrew Hume
Technical Details
Message-ID:
<497@cwjcc.CWRU.Edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!cwjcc!kiwi!chetReferences:
<8908231654.AA10031@dash.mitre.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!cwjcc!kiwi!chet From: chet@kiwi.CWRU.EDU (Chet Ramey) Newsgroups: gnu.bash.bug Subject: Re: parameter test Message-ID: <497@cwjcc.CWRU.Edu> Date: 24 Aug 89 00:50:38 GMT References: <8908231654.AA10031@dash.mitre.org> Sender: news@cwjcc.CWRU.Edu Reply-To: chet@kiwi.INS.CWRU.Edu (Chet Ramey) Distribution: gnu Organization: CWRU Andrew R. Jennings Computing Center Lines: 50