csh:フォーク時のアクション+ PIDの削除

csh:フォーク時のアクション+ PIDの削除

Bashでは、次のことができます。

$ ssh bashuser@localhost '( ls -d / nosuchfile ) & echo foo; wait'
foo
ls: cannot access nosuchfile: No such file or directory
/

cshを使用して同じことをしようとすると、次の結果が表示されます。

$ ssh cshuser@localhost '( ls -d / nosuchfile ) & echo foo; wait'
[1] 187253
foo
ls: cannot access nosuchfile: No such file or directory
/
[1]    Exit 2                 ( ls -d / nosuchfile )

bashと同じ出力を得たいです。避ける方法[1] PID[1] Exit ...?どういうわけか自動モードに入ることができますかcsh

もちろん、lsこれはecho foo単なる例です。実際にははるかに複雑で、ログインシェルで実行しているかどうかに応じてstdoutとstderrが必要なので、単純なgrep -v出力は機能しません。

ベストアンサー1

魔法なしではできないようです(つまり、オプションはありません)。ただし、以下を使用できますsh -c

$ ssh cshuser@localhost 'sh -c "( ls -d / nosuchfile ) & echo foo; wait"'   
foo
ls: nosuchfile: No such file or directory
/

bashIMHO、とにかくこれが最善の選択です。なぜなら&より多くのシェルがありcsh(例えばfish)、そのうちのどれの動作も保証できないからです。

おすすめ記事