bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Severe Bash Bug with Arrays


From: Greg Wooledge
Subject: Re: Severe Bash Bug with Arrays
Date: Wed, 25 Apr 2012 10:55:10 -0400
User-agent: Mutt/1.4.2.3i

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]