[gnu.bash.bug] parameter tests in Bourne shell

frew%crseo@HUB.UCSB.EDU (Jim Frew) (08/24/89)

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

bfox@AUREL.CALTECH.EDU (Brian Fox) (08/24/89)

   From: Jim Frew <frew%crseo@hub.ucsb.edu>
   Date: 23 Aug 1989 1927-PDT (Wednesday)

   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.


The ":" isn't what we are complaining about, it is the "?" that is
causing the behaviour in question.

Brian Fox