Fish shell command subsitution

2019-04-07 19:50发布

Is there a better way to do command substitution in fish shell?

In bash I can do:

~> echo $(whoami) => user
~> echo "I am: $(whoami)" = > I am: user

But in fish is looks like I have to do:

~> echo (whoami) => user
~> echo "I am: (whoami)" => "I am: (whoami)"
~> set who (whoami); echo "I am: $who" => I am: user

Is that the recommended way to do command substitution in fish where the substitution needs to happen inside a quoted string?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-04-07 20:36

You could just pull the substitution out of the quotes

echo "I am:" (whoami)
查看更多
登录 后发表回答