public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
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:21:00 -0000	[thread overview]
Message-ID: <CADPb22TQcHeyXqcv5ENZ9sEM5DokqyCjyt3dONQAjLn_YspmPg@mail.gmail.com> (raw)
In-Reply-To: <CA+C-WL94mhYR4xtquXuR8U6D8Sia7jWhLE-vq=PCKJAE56xEug@mail.gmail.com>

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.

  parent reply	other threads:[~2015-06-22 13:21 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 [this message]
2015-06-22 13:46       ` Patrick Palka
2015-06-22 13:59         ` Doug Evans

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=CADPb22TQcHeyXqcv5ENZ9sEM5DokqyCjyt3dONQAjLn_YspmPg@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).