bug-bash
[Top][All Lists]
Advanced

[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: Wed, 29 Apr 2015 19:11:05 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 4/27/15 2:26 AM, isabella parakiss wrote:
> On 4/27/15, Chet Ramey <address@hidden> wrote:
>> 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.
>>
> 
> Ok I understand, but would it be possible to add it?

It really doesn't make sense.

Since you're writing your file once, why not just grep the output
of `set'?  That will give you proper quoting without the `declare'.

-- 
``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]