From: Doug Evans <dje@google.com>
To: Patrick Palka <patrick@parcs.ath.cx>
Cc: Pedro Alves <palves@redhat.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Test the interaction between GDBHISTSIZE and .gdbinit
Date: Mon, 22 Jun 2015 13:59:00 -0000 [thread overview]
Message-ID: <CADPb22R3bdqcX==qqWWLbSRn54jStLWPncvP=WUB3ACNquEk_g@mail.gmail.com> (raw)
In-Reply-To: <CA+C-WL9WcG8fYpyB+8W+jRqdhE9d=ODJNtNxKEo+TZP3MvU0CA@mail.gmail.com>
On Mon, Jun 22, 2015 at 8:46 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Mon, Jun 22, 2015 at 9:21 AM, Doug Evans <dje@google.com> wrote:
>> 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.
>
> The env array is "magical" so I'm not sure if these techniques may work on it.
Well, that's unfortunate.
https://www.tcl.tk/man/tcl8.5/TclCmd/tclvars.htm
"If the entire env array is unset then Tcl will stop monitoring env
accesses and will not update environment variables."
Still, it should be possible to write the equivalent.
I'll look at the save_vars patch.
prev parent reply other threads:[~2015-06-22 13:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 20:17 Patrick Palka
2015-06-18 9:06 ` Pedro Alves
2015-06-18 12:45 ` Patrick Palka
2015-06-18 14:47 ` Patrick Palka
2015-06-18 15:29 ` Pedro Alves
2015-08-11 22:11 ` Pedro Alves
2015-08-12 12:44 ` Patrick Palka
2015-06-23 16:48 ` Doug Evans
2015-06-22 13:21 ` Doug Evans
2015-06-22 13:46 ` Patrick Palka
2015-06-22 13:59 ` Doug Evans [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADPb22R3bdqcX==qqWWLbSRn54jStLWPncvP=WUB3ACNquEk_g@mail.gmail.com' \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=patrick@parcs.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox