Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.UUCP Newsgroups: net.unix Subject: Re: Variations across unices Message-ID: <4289@sun.uucp> Date: Thu, 19-Jun-86 19:37:40 EDT Article-I.D.: sun.4289 Posted: Thu Jun 19 19:37:40 1986 Date-Received: Sat, 21-Jun-86 12:19:46 EDT References: <1037@umd5.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 35 > > eval tr '"[A-Z][a-z]" "[N-Z][A-M][n-z][a-m]"' ${1:+'<$1'} > ^ > What good is this colon? We were speculating that it might serve to > terminate a numeric expression a la ${foo+bar-1:+defalt} but were not > able to get this shell script to work until the colon be removed. See previous postings concerning alleged "incompatibility" between 4.2BSD and Sun UNIX 3.0. "${1+'<$1'}" means if "$1" (first parameter to the script) is set (i.e., a parameter was supplied to the script), substitute "<$1", otherwise substitute nothing. Thus, if an argument is supplied, "tr" has its input redirected to the argument supplied, otherwise it reads from the standard input. "${1:+'<$1'}" means if "$1" is set and is non-null, substitute "<$1", otherwise substitute nothing. The ":" is a feature of the S3 and later shells, and isn't in the 4.2BSD shell, which is why it didn't work until you removed it. It's not really necessary. > We also had to remove the [square brackets] for it seems that "tr" on this > system not only doesn't need them but treats them as normal characters! > ... > Are there in fact variant unices that require the [square brackets] > on "tr" commands and allow integer expressions in ${parm+defalt} lists? Yes to the first (for some reason, the S5 and, I think, S3 versions of "tr" require the square brackets) and no to the second (the "1" refers to the first argument, and is not a numeric value). > Or is this just somebody's idea of a bad joke? Unless there was a good reason to incompatibly change the syntax of "tr" from what AT&T's own V7 supported, one could argue that the USDL perpetrated a bad joke on us all by doing so.... -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)