jc@minya.UUCP (John Chambers) (01/05/91)
> >The problem is that I can't figure out any Bourne-shell expression that > >gives the last argument. In C-shell, it's easy (argv[$#]). But I need > >to write Bourne shell scripts. In fact, they need to be BSD bourne shell > >scripts rather that ATT Bourne shell scripts. The difference is probably > >significant here, because of the differences in the way these two Bourne > > As an aside, could you explain this comment? I have had minimal contact > with BSD, but my experience does not seem to support this statement. Well, one difference that has bitten me is ${x-foo} versus: ${x:-foo} Often only one of these is accepted by any particular /bin/sh, and the other is a syntax error. Sometimes both are accepted (with different meanings). BSD /bin/sh usually only understands the first format, and the script dies if you use the second format. (Isn't it wonderful to have such a nice tool for portable scripts? ;-) -- Zippy-Says: Imagine ... a world without clothing folds, chiaroscuro, or marital difficulties ... Home: 1-617-484-6393 Work: 1-508-952-3274 Uucp: ...!{harvard.edu,ima.com,eddie.mit.edu,ora.com}!minya!jc (John Chambers) Uucp-map: minya adelie(DEAD)
Dan_Jacobson@ATT.COM (01/07/91)
>>>>> On 5 Jan 91 14:35:27 GMT, jc@minya.UUCP (John Chambers) said:
John> ${x-foo}
John> versus:
John> ${x:-foo}
John> Often only one of these is accepted by any particular /bin/sh, and the
John> other is a syntax error.
My understanding is that the first should always work, and the second
should work in newer /bin/sh's with this added bonus feature [BSD 4.3
/bin/sh doesn't accept it, like you mentioned].
--
Dan_Jacobson@ATT.COM Naperville IL USA +1 708-979-6364
davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (01/09/91)
In article <442@minya.UUCP> jc@minya.UUCP (John Chambers) writes: | Often only one of these is accepted by any particular /bin/sh, and the | other is a syntax error. Sometimes both are accepted (with different | meanings). I don't dispute what you say, but I have never seen a sh which didn't buy {$a-b} notation. Of course the meaning is different when both are available, the whole : set of expansions was added about SysIII (my SysIII system is down or I'd check). ${a-b} if $a is undefined use b instead ${a:-b} if $a is undefined *or null* use b instead and so on for all the other operators. -- bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen) sysop *IX BBS and Public Access UNIX moderator of comp.binaries.ibm.pc and 80386 mailing list "Stupidity, like virtue, is its own reward" -me