Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!mcsun!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Macro facility in csh? Message-ID: <3117@solo12.cs.vu.nl> Date: 1 Sep 89 21:28:58 GMT References: <8998@zodiac.ADS.COM> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 43 charleen@zodiac.ADS.COM (Charleen Bunjiovianna) writes: \I may be asking for too much, but I write a lot of csh scripts and \it sure would be handy to have macro capability. I don't find any \mention of it in the documentation, though. There always has been a macro facility (!): set foo = bar ... $foo ... $foo ... $foo ... Allright, you want macros with PARAMETERS: well, why don't you filter your script through `/lib/cpp -P' before passing it to the shell? If you would use *Bourne* shell scripts, you could even define shell FUNCTIONS: foo() { ... } ... foo ... If you're stuck with an old version of the Bourne shell, try the following trick: foo=' case $1 in bar) date ;; pipo) who esac ' ... set bar; eval "$foo" set pipo; eval "$foo" In fact, this is the way functions were implemented at first: the shell would set the arguments you gave and eval the function shell variable. The problem: the (global) positional parameters get overwritten on each call, making nested functions somewhat `tricky'... -- C, the programming language that's the same |Maarten Litmaath @ VU Amsterdam: in all reference frames. |maart@cs.vu.nl, mcvax!botter!maart