barratt@DASH.MITRE.ORG (Jeff Barratt) (08/23/89)
Bash Version 1.02 Sun OS-4.0.1, Sun 3/50 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 ---------------------- barratt@dash.mitre.org I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered. - The Prisoner
chet@kiwi.CWRU.EDU (Chet Ramey) (08/24/89)
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