Path: utzoo!attcan!uunet!husc6!purdue!mentor.cc.purdue.edu!s.cc.purdue.edu!ksb From: ksb@s.cc.purdue.edu (Kevin Braunsdorf) Newsgroups: comp.unix.wizards Subject: ${PARAM[-=]'echo word'} follow up Keywords: Was: ${PARAM-'echo word'} vs ${PARAM='echo word'} Message-ID: <3724@s.cc.purdue.edu> Date: 15 Jan 89 00:30:20 GMT Reply-To: ksb@s.cc.purdue.edu (Kevin Braunsdorf) Followup-To: poster Distribution: na Organization: Purdue UNIX Group Lines: 41 I wrote: >I want an environment variable `ROFF' to be an nroff/troff/DITroff >command (if set). I want the default to be `nroff -man' so I try: > ${ROFF-'nroff -man'} $file > >to which the shell replys > sh: nroff -man: not found > >clever me tries > ${ROFF='nroff -man'} $file > >and it works! But *only* on 1/2 of the machines I try it on. > .... [Which is correct?] ... This is a summary of the replies I have: Some people told me `what the problem was'; maybe I did not make myself clear. I know about quoting, what I am trying to discover is `how many times *should* the word after the `=' be evaluated?' Chris Torek tells me that it is worse than I thought, under some shells the space still is a meta-space even after the assignement, so: $ : ${ROFF='nroff -man'} $ $ROFF $file sh: nroff -man: not found Then I looked at what ksh does. It does 2 evals and gets no meta- space in Chris's case (above). I conclude, then, that the word after the `=' *should* be evaluated twice. (And Chris's example above should work.) Which only means I have a list of broken shells! -- kayessbee, Kevin Braunsdorf, ksb@j.cc.purdue.edu, pur-ee!ksb, PUCC UNIX Group