bug-bash
[Top][All Lists]
Advanced

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

Re: nameref bug?


From: lolilolicon
Subject: Re: nameref bug?
Date: Wed, 3 Sep 2014 02:18:25 +0800

On Tue, Sep 2, 2014 at 8:59 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> On Sat, Aug 30, 2014 at 12:02:33PM +0800, lolilolicon wrote:
>> > #!/bin/bash
>> > declare var="hello world"
>> > declare -n ref
>> > ref=var
>> > echo $ref
>> > ref=var
>> > echo $ref
>> >
>> > --- output ---
>> > hello world
>> > var
>
>> Ah, LOL I think I need some sleep. This is not a bug. Sorry for all the 
>> noise.
>
> For those trying to follow along, what's happening is the first time
> "ref=var" is executed, ref becomes a reference to the variable var.
> The second time "ref=var" is executed, ref is already a reference to a
> variable, so the value "var" is assigned to the variable "var".
>
> imadev:~$ declare -n ref=var1
> imadev:~$ var1=old
> imadev:~$ declare -p ref var1
> declare -n ref="var1"
> declare -- var1="old"
> imadev:~$ ref=new
> imadev:~$ declare -p ref var1
> declare -n ref="var1"
> declare -- var1="new"
>

Indeed this seems worth adding to the Greg's Wiki!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]