Delayed evaluation of csh variables?
Chris Shenton
chris at asylum.gsfc.nasa.gov
Wed Dec 12 04:37:53 AEST 1990
Thanks to everyone who responded (mail and posts) on my query. This is a
``best-of'' from the suggestions.
1. The quoting can be simplified by nixing the " and using ' instead.
2. Eval -- this is the key -- is needed to instantiate the variable in the
string.
Here's the simplest example thing I've come up with:
#!/bin/csh -vxf # show whazzup; ignore .cshrc
set COMMAND = 'ls -l $File' # simple single quotes do the trick
foreach File ( $* ) # do all command line arguments
eval $COMMAND # eval to instantiate $File
end
tchrist at convex.com insists that I shouldn't be doing any programming in
csh. Probably true, but I'm too lazy to get intimate with sh for such short
stuff. (I'd rather learn bash!)
Again, many thanks to everyone.
Ciao!
--
chris at asylum.gsfc.nasa.gov, ...!uunet!asylum.gsfc.nasa.gov!chris, PITCH::CHRIS
More information about the Comp.unix.shell
mailing list