[Top][All Lists]

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

Re: nameref bug?

From: Greg Wooledge
Subject: Re: nameref bug?
Date: Tue, 2 Sep 2014 08:59:15 -0400
User-agent: Mutt/

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"

reply via email to

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