FishShellでエラー
Command Substitutionが使えない?!
FishShellを使っている中で、shellによくある$(コマンド)...みたいな記述を実行しようとすると、以下のようなエラーが出ると思います。
fish: Command substitutions not allowed
むむっ。
FishShellでは、Command substitutionsは許可されていないらしいですね。
詳細は以下の公式ページを見てみると良いでしょう。
The output of a series of commands can be used as the parameters to another command. If a parameter contains a set of parenthesis, the text enclosed by the parenthesis will be interpreted as a list of commands. On expansion, this list is executed, and substituted by the output. If the output is more than one line long, each line will be expanded to a new parameter. Setting IFS to the empty string will disable line splitting.fish: Documentation
では、どうすれば良いのでしょうか・・・orz
対処方法
evalで解決
解決方法はとても簡単で$(コマンド)...となっている部分をeval (コマンド)...と変えることで同様の期待を得る事が出来ます。
ちなみに、evalの後には半角スペースが必要なので気をつけましょう。
終わりに
以上のように、bashやzshで動いていた部分が動かなくなってしまう原因の一つとなっています。
もしお困りの際は、こちらの方法を試してみてください♪
