[Top][All Lists]

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

Re: `declare -a NAME` followed by `declare -p NAME`

From: Chet Ramey
Subject: Re: `declare -a NAME` followed by `declare -p NAME`
Date: Tue, 06 Jan 2015 09:00:40 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 1/4/15 9:31 PM, Ivan Shapovalov wrote:
> If an empty array is declared using `declare -a NAME` and then immediately
> `declare -p NAME` is invoked, it says there is no such variable. 

A variable is not set until it is assigned a value.  `declare -p name' only
finds set variables.

> However, the array can be found in output of `declare -p` without NAME given.

Yes, since that is supposed to produce output that can recreate all
variables with their attributes, even unset variables.

This is a common enough request that I have changed the behavior of
`declare -p name' for the next bash release, and it will display variables
that are not set but have been given attributes.


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