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: Chet Ramey
Subject: Re: unset does not act as expected on namerefs
Date: Wed, 27 May 2015 10:28:44 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 5/26/15 5:02 PM, Shawn Wilson wrote:
> On +2015/05/26 18:05:18, Geir Hauge wrote:
>> On Tue, May 26, 2015 at 11:00:45AM -0500, Eduardo A. Bustamante López wr
ote:
>>> # Here we 'unset ref', which actually unsets 'var'. Then, we assign 'va
r' to
>>> # 'ref', but since 'ref' is still a nameref, it instead assigns 'var' t
o 'var'.
>>> address@hidden:~$ unset ref; ref=var; echo "$ref"; declare -p ref
>>> var
>>> declare -n ref="var"
>>> address@hidden:~$ declare -p var
>>> declare -- var="var"
>>
>> Ah, that explains it! Mystery solved, and no longer surprising behavior.
>>
> 
> If there's no good reason to keep this as is (some use case where
> this might be wanted and breaking backward compatibility - I can't
> see anyone actually *wanting* it this way) shouldn't it be changed?
> A behavior can be documented and still be bad.

What behavior do you want? That namerefs should act transparently (that
is, use the nameref variable's non-null value as the variable name to
operate on) in all contexts *except* unset?

- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlVl1JQACgkQu1hp8GTqdKudNQCeJn533z6DE//zfQLMVFctElOg
DXkAniyUQHTEfGXcYJTqWHBJDgTOW4pG
=Jrw3
-----END PGP SIGNATURE-----



reply via email to

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