Path: 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 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