[Toybox] Endless bash questions...
Chet Ramey
chet.ramey at case.edu
Sat Jun 4 15:15:28 PDT 2022
On 6/4/22 6:08 PM, Rob Landley wrote:
> Why does this work:
>
> $ [[ $(cat) == "a b" ]] <<< "a b" > potato && rm potato && echo yes
> yes
Here-strings are redirections, and a redirection may follow a compound
command.
> But this is an error?
>
> $ [[ $(cat) == "a b" ]] <(echo a b) > potato && rm potato && echo yes
> bash: syntax error near unexpected token `<(echo a b)'
Process substitution is a word expansion, and so words consisting only of
process substitutions are words, and words may not follow a compound
command.
> It actually seems to exclude <(subcommands) from all trailing blocks?
Anywhere a word is not allowed.
> $ if true; then cat; fi <(echo hello)
> bash: syntax error near unexpected token `<(echo hello)'
Like here.
>
> Maybe it's related to restartability?
>
> $ a() { cat; } <<< potatosalad
> $ a
> potatosalad
> $ a
> potatosalad
> $ a() { cat; } <(echo hello)
> bash: syntax error near unexpected token `<(echo hello)'
And here.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet at case.edu http://tiswww.cwru.edu/~chet/
More information about the Toybox
mailing list