I stuck with an strange behaviour of readarray command.The man bash states:readarray     Read lines from the standard input into the indexed array variable arraybut these scripts don't work (array is empty):unset arr; (echo a; echo b; echo c) | readarray arr; echo ${#arr[@]}unset arr; cat /etc/passwd | readarray arr;  echo ${#arr[@]}And these work:unset arr; readarray arr < /etc/passwd ;  echo ${#arr[@]}unset arr; mkfifo /tmp/fifo; (echo a; echo b; echo c) > /tmp/fifo & mapfile arr < /tmp/fifo ; echo ${#arr[@]}What wrong with pipe?
readarray (or pipe) issue
bash;pipe
Maybe try:unset arrprintf %s\\n a b c | {    readarray arr    echo ${#arr[@]}}I expect it will work, but the moment you step out of that last { shell ; } context at the end of the |pipeline there you'll lose your variable value. This is because each of the |separate | processes within a |pipeline is executed in a (subshell). So your thing doesn't work for the same reason:( arr=( a b c ) ) ; echo ${arr[@]}...doesn't - the variable value was set in a different shell process than the one in which you call on it.