[pacman-dev] [PATCH] Make strip paths configurable

Henning Garus henning.garus at googlemail.com
Mon Jul 28 20:06:48 EDT 2008


On Mon, 28 Jul 2008 23:44:13 +0200
Xavier <shiningxc at gmail.com> wrote:

> Anyway, I have something else, look :
> [xavier at nx7400 ~]$ array=('' {foo,bar,baz})
> [xavier at nx7400 ~]$ [ -z "${array[@]}" ] || echo array not empty
> bash: [: too many arguments
> array not empty
> [xavier at nx7400 ~]$ [ -z "${array[*]}" ] || echo array not empty
> array not empty
> 
> I never understood what the differences between @ and * were though...
> 


The way I understand it "${array[@]}" is expanded to "foo" "bar" "baz",
while "${array[*]}" is expanded to "foo%bar%baz" where % is the first
character of $IFS (meaning ' ' if not set otherwise).

So with @ you get several words for the test, which would explain the
observed behaviour.

Interestingly enough [[ -z "${array[@]}" ]] seems to work as well...




More information about the pacman-dev mailing list