On Mon, Jul 28, 2008 at 11:05 PM, Aaron Griffin <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 28, 2008 at 3:51 PM, Xavier <[EMAIL PROTECTED]> wrote:
>> On Mon, Jul 28, 2008 at 10:45 PM, Aaron Griffin <[EMAIL PROTECTED]> wrote:
>>>
>>> [EMAIL PROTECTED]:~$ [ -z foo bar baz ]
>>> -bash: [: too many arguments
>>> [EMAIL PROTECTED]:~$ [ -z "foo bar baz" ]
>>> [EMAIL PROTECTED]:~$
>>
>>
>> Well don't ask me to explain, but here is a closer test case I think :
>>
>> [EMAIL PROTECTED] ~]$ array=({foo,bar,baz})
>> [EMAIL PROTECTED] ~]$ [ -z "[EMAIL PROTECTED]" ]
>> bash: [: too many arguments
>
> Weird. I'd guess this is something to do with globbing taking
> priority. Seeing as this is just testing for some value, using single
> quotes fixes the issue.
>
> _______________________________________________
> pacman-dev mailing list
> [email protected]
> http://archlinux.org/mailman/listinfo/pacman-dev
>
With single quotes, I am not sure it still works correctly.
[EMAIL PROTECTED] ~]$ unset array
[EMAIL PROTECTED] ~]$ [ -z '[EMAIL PROTECTED]' ] || echo array not empty
array not empty
[EMAIL PROTECTED] ~]$ echo '[EMAIL PROTECTED]'
[EMAIL PROTECTED]
What about handling it just like a normal variable ?
[EMAIL PROTECTED] ~]$ array=({foo,bar,baz})
[EMAIL PROTECTED] ~]$ [ -z "$array" ] || echo array not empty
array not empty
[EMAIL PROTECTED] ~]$ unset array
[EMAIL PROTECTED] ~]$ [ -z "$array" ] || echo array not empty
[EMAIL PROTECTED] ~]$
_______________________________________________
pacman-dev mailing list
[email protected]
http://archlinux.org/mailman/listinfo/pacman-dev