[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare -p doesn't show the global attribute
From: |
Chet Ramey |
Subject: |
Re: declare -p doesn't show the global attribute |
Date: |
Sun, 26 Apr 2015 22:36:41 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 4/26/15 5:26 PM, isabella parakiss wrote:
> $ fn () { declare -g var=x; declare -p var; } ; fn
> declare -- var="x"
>
> I think the correct output should be declare -g var="x"
> Is this intended or is it a bug?
There is no such thing as `the global attribute'. The -g option simply
causes declare to create variables at the global scope instead of in a
function-local scope. The output you see is no different than what
would have been displayed had `var' been declared and given a value at
the global scope outside the function.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/