🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Jeff Barratt Wed, 23 Aug 1989 16:54
parameter test
#490
Author: Jeff Barratt
Date: Wed, 23 Aug 1989 16:54
17 lines
801 bytes
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
Re: parameter test
#494
Author: Chet Ramey
Date: Thu, 24 Aug 1989 00:50
50 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads