This is not a bug but the expected behavior.

Due to the use of a pipe, "readarray blah" is executed in a sub-shell.
But "echo ${blah[@]}" is executed in the parent shell. This has nothing
to do with readarray, the command ": | blah=blah; echo $blah" would also
fail to output blah.

On the other hand, this will work because both readarray and echo execute in 
the same subshell:
$ cat /tmp/foo | ( readarray blah; echo "${blah[@]}" )

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1376329

Title:
  readarray doesn't work with pipes

Status in bash package in Ubuntu:
  New

Bug description:
  (echo one 1 ; echo two 2 ; echo three 3) > /tmp/foo

  #works
  readarray blah < /tmp/foo
  echo "${blah[@]}"

  # doesn't work:
  unset blah
  cat /tmp/foo | readarray blah
  echo "${blah[@]}"

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1376329/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to