patorashのブログ

方向性はまだない

fishのCommand Substitutionsは戻り値を1つと判断するので注意

fishでスクリプトの実行結果を複数渡そうとしたところ、うまく動きませんでした。bashでは動いたのに…。

# bash: Working!!
bin/rspec $(bin/rails runner scripts/get_failed_spec_files.rb)
# fish: Not working...
bin/rspec (bin/rails runner scripts/get_failed_spec_files.rb)

原因

fishのチュートリアルのところに書いてありました。

Command substitutions use the output of one command as an argument to another.

fishshell.com

解決方法

解決方法は、string splitを使え、とのこと。

# fish: Working!!
bin/rspec (bin/rails runner scripts/get_failed_spec_files.rb | string split " ")

うーむ、fishは便利なんだけれど時々こういうのでハマる…。