Bashバージョン4.2.47(1)リリースでは、次のようにHERE文書のリッチテキストをリンクしようとすると、次のようになります。
cat <(fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
) # I want this paranthesis to end the process substitution.
次のエラーが発生します。
bash: bad substitution: no closing `)' in <(fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
)
また、HEREドキュメント(writeなど)を参照したくありません。<'FOOBAR'
なぜならまだそこにある変数を変えたいからです。
ベストアンサー1
これは古い質問であり、これが人工的な例であることがわかったら、一般的なケースに対する答えを投稿します。したがって、正しい解決策は、この場合は使用するか、cat |
まったく使用しないことです。cat
関数に入れて使って解決します。
fmt-func() {
fmt --width=10 <<FOOBAR
(I want the surrounding parentheses to be part of the HERE-document)
(Even the preceding unbalanced parenthesis should be part of it.
FOOBAR
}
それからそれを使う
cat <(fmt-func)