On 5/12/14, 9:33 AM, Geir Hauge wrote:
> 2014-05-12 14:11 GMT+02:00 Greg Wooledge <[email protected]>:
>
>> On Sat, May 10, 2014 at 12:22:40PM +0200, thioroup8 wrote:
>>> Now, I source it from inside a function: I obtain following error
>> message:
>>> bash: declare: tmp: not found
>>> I think this problem raises in the particular case of involving array
>>> variables definitions inside sourced bash script file...
>>
>>> cat << "EOF" > "${file_to_be_sourced}"
>>> declare -a tmp='([0]="1" [1]="2")'
>>> EOF
>>
>> The problem is that you are using "declare" within the file-to-be-sourced.
>> When you source the file inside a function, Bash runs the declare command
>> within the context of the function, where declare has the same meaning as
>> "local". Thus, it makes the variable local to the function.
>
>
> There really is a bug here, a weird one. Using a simplified script, we
> see that this works as expected:
Yep. Thanks for the report. The issue is that the `placeholder' attribute
doesn't get unset when the argument is quoted -- it takes a different code
path than when it's unquoted. I've attached a patch for people to
experiment with.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.3-patched/arrayfunc.c 2014-03-28 10:54:21.000000000 -0400
--- arrayfunc.c 2014-05-12 11:19:00.000000000 -0400
***************
*** 180,183 ****
--- 180,184 ----
FREE (newval);
+ VUNSETATTR (entry, att_invisible); /* no longer invisible */
return (entry);
}