From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68444 invoked by alias); 22 Jun 2015 13:21:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 68431 invoked by uid 89); 22 Jun 2015 13:21:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f181.google.com Received: from mail-ob0-f181.google.com (HELO mail-ob0-f181.google.com) (209.85.214.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 22 Jun 2015 13:21:45 +0000 Received: by obbkm3 with SMTP id km3so19823238obb.1 for ; Mon, 22 Jun 2015 06:21:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2xr0Iwz0+oiDvXlMJoH+v0Zp3sFl8fkHyiYAXqUp2qM=; b=Pmu9zlCBBTTd21TAoh+c9grEGcb4vPwIWWxKd30wbIasC0WJZqhYpx1Jfd68bm3tpq Ga+XzpIu0c+QwOxnw24uHqsbvqsib5OoaDoA5IcdQ+qhckCKKUbwLcURAzJKZS7mGhCT srKruy89IztIAqZzIClgBsSqd/64nGo/0Ce8IEhJUlVaJTMMjo39auNM6M0E9NuXwrX3 pxv5u/HOZvI0Ji+lYa2k3LKzKDAPXCZNJABbz/OeFP3MmzkmiEql1BpkV7jrihu2Y9SX AMk0YVRft6SirOshEuSTtBoOoxof9ulD3DDkat7QxWFaJJ6q1pzIidnTe8YBJsXdC/WL 2l5g== X-Gm-Message-State: ALoCoQl4lFx2RNepxd/n0tNzDen62siIlD5M2AKO2ENFpYuRTqUQxOHcZWzQmkdLHOwIUxY8kY2i MIME-Version: 1.0 X-Received: by 10.60.155.97 with SMTP id vv1mr25064797oeb.15.1434979303355; Mon, 22 Jun 2015 06:21:43 -0700 (PDT) Received: by 10.182.89.99 with HTTP; Mon, 22 Jun 2015 06:21:43 -0700 (PDT) In-Reply-To: References: <1434572241-16019-1-git-send-email-patrick@parcs.ath.cx> <55828A13.8030703@redhat.com> Date: Mon, 22 Jun 2015 13:21:00 -0000 Message-ID: Subject: Re: [PATCH] Test the interaction between GDBHISTSIZE and .gdbinit From: Doug Evans To: Patrick Palka Cc: Pedro Alves , "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00438.txt.bz2 On Thu, Jun 18, 2015 at 7:44 AM, Patrick Palka wrote: > On Thu, Jun 18, 2015 at 5:06 AM, Pedro Alves 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.