bug-bash
[Top][All Lists]
Advanced

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

Re: param expansion with single-character special vars in the environmen


From: Eduardo A . Bustamante López
Subject: Re: param expansion with single-character special vars in the environment
Date: Wed, 27 Apr 2016 13:16:04 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

On Wed, Apr 27, 2016 at 08:41:20AM -0400, Grisha Levit wrote:
[...]
> The above works when the readonly variable has a value that is also a valid
> identifier. In my previous example I worked around this using the fact
> that ref=<whatever>;
> declare -n ref does not check to make sure that $ref is a valid identifier.
[...]

It does seem to check, but only when you do: declare -n ref=<whatever>

|  dualbus@hp ...src/gnu/bash % gdb ./bash --batch -ex 'b sh_invalidid' -ex r 
--args bash -c 'declare -n r=@'  
|  Breakpoint 1 at 0x493107: file common.c, line 236.
|  
|  Breakpoint 1, sh_invalidid (s=0x7dd26a "@") at common.c:236
|  236       builtin_error (_("`%s': not a valid identifier"), s);
|
|  dualbus@hp ...src/gnu/bash % gdb ./bash --batch -ex 'b sh_invalidid' -ex r 
--args bash -c 'declare -n r; r=@' 
|  Breakpoint 1 at 0x493107: file common.c, line 236.
|  [Inferior 1 (process 5609) exited normally]

As you can see, in the first case, it hits the sh_invalidid breakpoint, and
bash actually complains about the invalid identifier.

-- 
Eduardo Bustamante
https://dualbus.me/



reply via email to

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