On Tue, Jul 29, 2008 at 2:06 AM, Henning Garus
<[EMAIL PROTECTED]> wrote:
> On Mon, 28 Jul 2008 23:44:13 +0200
> Xavier <[EMAIL PROTECTED]> wrote:
>
>> Anyway, I have something else, look :
>> [EMAIL PROTECTED] ~]$ array=('' {foo,bar,baz})
>> [EMAIL PROTECTED] ~]$ [ -z "[EMAIL PROTECTED]" ] || echo array not empty
>> bash: [: too many arguments
>> array not empty
>> [EMAIL PROTECTED] ~]$ [ -z "${array[*]}" ] || echo array not empty
>> array not empty
>>
>> I never understood what the differences between @ and * were though...
>>
>
>
> The way I understand it "[EMAIL PROTECTED]" 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 "[EMAIL PROTECTED]" ]] seems to work as well...
>
Hmm now we have too many solutions and I don't know which one to choose.
1) [ -z "$array" ]
2) [ -z "${array[*]}" ]
3) [[ -z "[EMAIL PROTECTED]" ]]
(the current problematic one is [ -z "[EMAIL PROTECTED]" ] ).
So you can vote now :)
_______________________________________________
pacman-dev mailing list
[email protected]
http://archlinux.org/mailman/listinfo/pacman-dev