setting variables in tcsh temporarily

Geert Hendrickx geert.hendrickx at ua.ac.be
Mon Jun 14 19:03:29 PDT 2004


Hi, 

I have this simple question regarding the tcsh: 

in /bin/sh (Bourne shell) I can assign a value to an environment variable for
just one command, like this: 

VARIABLE=value <command>

e.g. "DISPLAY=:0 xterm" or "CFLAGS=O2 make".  

Can this be done with tcsh as well?  The only thing I can think of is this:

( setenv VARIABLE value ; <command> )

thus invoking a subshell, because for example the multiline variant

setenv DISPLAY :0
xterm
unsetenv DISPLAY

"forgets" the (possible) original value of the variable.  

Thanks for any hints, this is the only Bourne-shell feature I'm missing in the
C-shell.  

GH


More information about the freebsd-questions mailing list