开发者

How to set an environment variable for just one command in csh/tcsh

开发者 https://www.devze.com 2023-03-04 15:28 出处:网络
In bash, I can set a temporary environment variable fo开发者_如何学JAVAr just one command like this:

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

精彩评论

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

关注公众号