bug-bash
[Top][All Lists]
Advanced

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

Re: unset does not act as expected on namerefs


From: Greg Wooledge
Subject: Re: unset does not act as expected on namerefs
Date: Tue, 26 May 2015 11:04:38 -0400
User-agent: Mutt/1.4.2.3i

On Tue, May 26, 2015 at 10:31:34AM -0400, Shawn Wilson wrote:
> address@hidden:~/temp$ bash --version
> GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
> address@hidden:~/temp$ cat t.txt 
> $ome text !n a file|
> address@hidden:~/temp$ unset t
> address@hidden:~/temp$ t=$(< ./t.txt)
> address@hidden:~/temp$ echo "$t"
> bash: $ome text !n a file|: invalid variable name for name reference
> address@hidden:~/temp$ var=foo; declare -n t; t=var; unset t; echo "$t"
> bash: $ome text !n a file|: invalid variable name for name reference

As surprising as that is, have a look at "help unset":

unset: unset [-f] [-v] [-n] [name ...]
    Unset values and attributes of shell variables and functions.
    
    For each NAME, remove the corresponding variable or function.
    
    Options:
      -f        treat each NAME as a shell function
      -v        treat each NAME as a shell variable
      -n        treat each NAME as a name reference and unset the variable 
itself
        rather than the variable it references



reply via email to

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