Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15953

Re: test -v for array does not work as documented

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: test -v for array does not work as documented
Date 2020-02-23 13:05 -0500
Organization ITS, Case Western Reserve University
Message-ID <mailman.1453.1582480579.2412.bug-bash@gnu.org> (permalink)
References (2 earlier) <a07dd152-b50a-a77b-13c1-fc559b053fdd@case.edu> <25b3fccb-151b-0712-76f1-5b19ffcce1d9@passchier.net> <9a084bb5-2362-b140-f3e8-9e18a0f1cac6@case.edu> <b7c08d7f-c41d-e4e4-c64f-df805518d753@passchier.net> <c4ab5d47-79b8-14b7-df3b-81acf425fa19@case.edu>

Show all headers | View raw


On 2/23/20 11:36 AM, pepa65 wrote:
> On 23/02/2020 23.27, Chet Ramey wrote:
>> On 2/21/20 3:31 AM, pepa65 wrote:
>>> By the way, it seems that `local -p var` doesn't work like 'declare -p
>>> var` even though `help local` suggests it should.
>>
>> How so? Do you mean that declare -p var in a function will show different
>> variables?
> 
> See this output:
> 
> localvsdeclare(){
>   local var
>   var=42
>   unset var
>   echo -n '"declare -p var":'
>   declare -p var
>   echo -n '"local -p var":'
>   local -p var
> }
> 
> localvsdeclare
> "declare -p var": declare -- var
> "local -p var":

Yes, it's always been this way. This behavior dates to March, 1995,
literally to the time I added `-p'. The reason for not making `local -p'
work the same has been lost to time, so let's try making it the same
and see what happens.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: test -v for array does not work as documented Chet Ramey <chet.ramey@case.edu> - 2020-02-23 13:05 -0500

csiph-web