开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜