Fish shell command subsitution

牧云@^-^@ 提交于 2019-12-21 04:26:26

问题


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:


You could just pull the substitution out of the quotes

echo "I am:" (whoami)


来源:https://stackoverflow.com/questions/22537730/fish-shell-command-subsitution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!