3

In bash one can write

CFLAGS="-O2" rvm install 2.0.0

to run rvm with that specific CFLAGS . Is there anyway to do the same in fish shell?

I know about set -x but that is not exactly the same as the environment variable will be set for the whole session instead of just for that command.

4

2 回答 2

4

根据 fish FAQ,要么使用:

env CFLAGS="-O2" rvm install 2.0.0

(这不适用于 fish 内置函数或函数,仅适用于外部命令),或

begin
    set -lx CFLAGS="-O2"
    rvm install 2.0.0
end

(这有点笨拙;在GitHub 问题 #438上有改进建议)。

于 2014-04-03T04:13:45.620 回答
3

您可以env为此使用命令:

env FOO=BAR command

将运行command环境变量 FOO 设置为 BAR。

于 2014-04-03T01:46:22.440 回答