[Top][All Lists]

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

Re: building arrays from non array variables using 'address@hidden'

From: Chet Ramey
Subject: Re: building arrays from non array variables using 'address@hidden'
Date: Tue, 26 Jan 2010 22:34:34 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 1/25/10 6:58 AM, Mart Frauenlob wrote:

> As i came up with this i have to go further ;) ,so i installed bash
> 4.1.2 and your new patch and ran tests again with it and 3.1.17, 4.0.35
> versions.
> Patch seems to be working for return values of 'address@hidden'.
> But address@hidden returns 0 on the declared but unassigned local variable
> - which i think should be the NULL string.

You're right.

> What worries me, is that v4.0.35 behaves weird with a local variable
> declared, as address@hidden always returns 1 inside the fill() loop.

Why does that worry you?  This is what I posted the patch to change.

> Also i noticed, that from bash 4 it looks like the declare builtin
> reacts differently. `declare -p var' on a globally declared but
> unassigned variable returns false, but for the same thing as a local
> variable it returns: `declare -- var=""' (with true as exit status of
> course).

It should return "declare -- var" in the function when used with a local
variable.  The minor inconsistency is for two reasons: to shadow any
global copy of the variable, since the normal behavior would be to ignore
it and people expect `declare var' to create a local variable, and to
save a reference to any other attributes, since users expect `declare -i
var' to perform arithmetic evaluation on a variable when it's assigned
a value.

The problem with this is that it leads to other minor inconsistencies,
two of which you found.  These will be fixed in the next version of bash.

Thanks for testing these details.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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