[Top][All Lists]

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

Re: change in behavior starting with bash-4.3_p14 and $@ in [[...]]

From: Greg Wooledge
Subject: Re: change in behavior starting with bash-4.3_p14 and $@ in [[...]]
Date: Wed, 13 Aug 2014 10:09:30 -0400
User-agent: Mutt/

On Wed, Aug 13, 2014 at 09:47:51AM -0400, Chet Ramey wrote:
> On 8/12/14, 11:05 PM, Mike Frysinger wrote:
> > foo=(0 0 0); [[ -z address@hidden ]]; echo $?

> Word splitting is
> suppressed inside [[, so the array expands to a single word ("0 0 0"), the
> 0s are removed, leaving "  "

That doesn't sound right.  Either you get a single word and remove the
leading 0 only, or you remove the 0s from each array element first,
and then get a single word by concatenating what's left.

The code that Mike posted is pretty wonky in the first place.  I don't
understand what its intent is.  (It's expanding an array into a list of
words in a context where you can't have a list... and then checking the
string length of that list-not-list as if it were a string... what?)

The right-hand side of an assignment also suppresses word splitting, so
I tried this:

imadev:~$ foo=(0 0 0); address@hidden
imadev:~$ echo "<$x>"
imadev:~$ foo=(0 0 0); x="address@hidden"
imadev:~$ echo "<$x>"
<  >
imadev:~$ echo $BASH_VERSION

Looks like the second one expanded to a list of empty words and then
concatenated them together with spaces.  I have no idea what the first
one did, or why it's different.

reply via email to

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