On Wed, Apr 25, 2012 at 08:40:11AM -0400, Chet Ramey wrote: > Since you're using bash-4.2, you can experiment with the `lastpipe' shopt > option. If that's enabled, bash runs the last element of a pipeline in > the parent shell context without creating a subshell.
I actually started writing a response that mentioned that, but when I was testing it, it didn't seem to work. The manual says job control has to be off, so I did it as a script: imadev:~$ cat foo #!/bin/bash set +m shopt -s lastpipe echo hi | read foo echo "<$foo>" printf '%s\n' some words | while read -r line; do myarray+=("$line"); done printf '<%s> ' "${myarray[@]}"; echo imadev:~$ ./foo <> <> imadev:~$ /bin/bash -c 'echo $BASH_VERSION' 4.2.20(8)-release This is the first time I've ever attempted to use lastpipe, so I'm not sure what's wrong.