sh changes

Comfy chair ken at rochester.ARPA
Wed Jun 18 03:25:36 AEST 1986


References:

I hit an incompatability between the 4.2 BSD sh and Sun 3.0 sh. Here
are the relevant parts of the manual pages:

>From 4.2 BSD system:

     ${parameter-word}
          If parameter is set, substitute its value; otherwise
          substitute word.
     ${parameter=word}
          If parameter is not set, set it to word; the value of
          the parameter is then substituted.  Positional parame-
          ters may not be assigned to in this way.
     ${parameter?word}
          If parameter is set, substitute its value; otherwise,
          print word and exit from the shell.  If word is omit-
          ted, a standard message is printed.
     ${parameter+word}
          If parameter is set, substitute word; otherwise substi-
          tute nothing.

>From Sun 3.0 system:

     ${parameter:-word}
          If parameter is set and  is  non-null,  substitute  its
          value; otherwise substitute word.
     ${parameter:=word}
          If parameter is not set or is null set it to word;  the
          value  of  the  parameter  is  substituted.  Positional
          parameters may not be assigned to in this way.
     ${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.
     ${parameter:+word}
          If parameter is set and is non-null,  substitute  word;
          otherwise substitute nothing.

In case you missed it, the difference is the extra colon in the Sun 3.0
system. Questions: when and why was this change made?  Are there any
other variants of Unix with this change? Has anybody's command file
broken on account of this?

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken at rochester.arpa
Snail: CS Dept., U. of Roch., NY 14627. Voice: Ken!



More information about the Comp.unix mailing list