[PATCH] Test the interaction between GDBHISTSIZE and .gdbinit
Doug Evans
dje@google.com
Mon Jun 22 13:21:00 GMT 2015
On Thu, Jun 18, 2015 at 7:44 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Thu, Jun 18, 2015 at 5:06 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 06/17/2015 09:17 PM, Patrick Palka wrote:
>>> The value inside the GDBHISTSIZE environment variable, only if valid,
>>> should override setting the history size through one's .gdbinit file.
>>
>> Thanks, looks good.
>>
>>> + unset -nocomplain env(GDBHISTSIZE)
>>> array set env [array get old_env]
>>
>> Though this unset looks unnecessary, given that the following line
>> restores the whole array.
>
> It turns out that
>
> array set env [array get old_env]
>
> does not completely restore the env array to its original state. What
> it seems to do is to reset each pre-existing environment variable
> (existing in the saved env array) to its original value. New
> environment variables that were set inside the env array in the
> meantime do not get unset after restoring.
http://tcl.tk/man/tcl8.5/TclCmd/array.htm
> So e.g. after doing
>
> array set old_env [array get env]
> set env(SOME_NEW_VAR) foo
> array set env [array get old_env]
>
> the environment variable SOME_NEW_VAR=foo will still be in the env
> array. So this "array set env" trick is insufficient. That is why
> the unset of GDBHISTSIZE is necessary there.
I haven't read the save_vars patch yet, but how about:
array set old_env [array get env]
...
array unset env ;# <<<<<<<<<<<<<<<
array set env [array get old_env]
array unset old_env
It might be a teensy bit simpler to do:
set old_env [array get env]
...
array set env $old_env
unset old_env
Dunno.
More information about the Gdb-patches
mailing list