In bash, I can set a temporary environment variable for just one command like this:
LD_LIBRARY_PATH=/foo/bar myprogram
Can I do something similar in csh / tcsh? I could do
setenv LD_LIBRARY_PATH /foo/bar; myprogram; unsetenv LD_LIBRARY_PATH
, but that will lose any previous value the variable had.
You can use the set or setenv command under c shell (tcsh/csh) to set an environment variable. Setting or modifying PATH. Set your default (preferred) editor. Set pager and more.
To set an environment variable, use the command " export varname=value ", which sets the variable and exports it to the global environment (available to other processes). Enclosed the value with double quotes if it contains spaces. To set a local variable, use the command " varname =value " (or " set varname =value ").
In csh, you can either try env
:
% env LD_LIBRARY_PATH=/foo/bar myprogram
or, a subshell:
% (setenv LD_LIBRARY_PATH /foo/bar; myprogram)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With