In this sequence at the command prompt
what causes the error noted?
Doing
runs without error, but executes the loop in a subprocess, losing the results on termination
BASH 3.2.57(1)-release on OS X 10.10.5
Code:
$ x=()
$ { while read; do x+=("$REPLY"); done; } <<<"$(ls)"
$ printf 'count=%d\n' ${#x[@]}
count=432
$ wc -l <(ls)
432 /dev/fd/63
$
$
$ { while read; do x+=("$REPLY"); done; } <(ls)
-bash: syntax error near unexpected token `<(ls)'
Doing
Code:
$ x=()
$ ls | { while read; do x+=("$REPLY"); done }
$ printf 'count=%d\n' ${#x[@]}
count=0
$
$
BASH 3.2.57(1)-release on OS X 10.10.5
Comment