🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #495

Re: parameter tests in Bourne shell

#495
From: Jim Frew
Date: Thu, 24 Aug 1989 02:27
35 lines
2043 bytes
In a recent bug-bash posting, cwjcc!kiwi!chet@gatech.edu (Chet Ramey) writes:

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

For the record, the use of ":" to test whether the parameter is null was NOT
documented in the 7th Edition Bourne shell.  The V7 manual page sez:

	${parameter?word}
		If parameter is set then substitute its value; otherwise,
		print word and exit from the shell.  If word is omitted then a
		standard message is printed.

Bourne's 1982 book "The UNIX System" doesn't mention the ":" either (see p.
63).  Since his book DOES mention System V, this leads me to believe that the
":" qualifier was a SVR2 invention (although it's not flagged as such in the
SVID).

This may seem a trivial point, unless you're trying to write portable shell
scripts (which is how I discovered it).  Hopefully a portable shell (i.e.
bash) will eliminate the need for this kind of software archaeology.

#-----------------+-----------------------+-----------------------------
# James Frew      | frew@crseo.ucsb.edu   | Computer Systems Lab., UCSB
# +1 805 961 8413 | frew@ucsbuxa (BITNET) | Santa Barbara, CA 93106, USA
Technical Details
Message-ID: <8908240229.AA18965@hub.ucsb.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!HUB.UCSB.EDU!frew%crseo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!HUB.UCSB.EDU!frew%crseo
From: frew%crseo@HUB.UCSB.EDU (Jim Frew)
Newsgroups: gnu.bash.bug
Subject: Re: parameter tests in Bourne shell
Message-ID: <8908240229.AA18965@hub.ucsb.edu>
Date: 24 Aug 89 02:27:00 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 35