How to set an environment variable for just one command in csh/tcsh
In bash, I can set a temporary environment variable fo开发者_如何学JAVAr 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.
In csh, you can either try env
:
% env LD_LIBRARY_PATH=/foo/bar myprogram
or, a subshell:
% (setenv LD_LIBRARY_PATH /foo/bar; myprogram)
精彩评论