From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58325 invoked by alias); 22 Jun 2015 13:46:37 -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 58316 invoked by uid 89); 22 Jun 2015 13:46:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-oi0-f52.google.com Received: from mail-oi0-f52.google.com (HELO mail-oi0-f52.google.com) (209.85.218.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 22 Jun 2015 13:46:34 +0000 Received: by oiyy130 with SMTP id y130so104617340oiy.0 for ; Mon, 22 Jun 2015 06:46:32 -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:from:date :message-id:subject:to:cc:content-type; bh=rKnrAjVYh237j6xrmYwEX2KOTOx/sNpfcafBR56KjT0=; b=NIJ9Xs53Yc/ymEoMzJXJJzYlWPieaW318QnmozfQ1dTl3jfmepdWM/lzVx2rOFv/Nt b/2CCV4sWSCJGhQf78jqTuhhVUYj7VmstCd+DBHH9L8agDBUYKrC++0yPy/DobNPyDvE YzKniTZFYw2EsnzgLEDVRMab4CLG+qYgNyzJgRbMr/JTfeugMkao3+FGAjwGptkOUGkv KTRKiezIx5lgVL+E/X7zw0NzROn5lfLic3Tia6lF9M18G9h/5S+SHuivup474tCV+sFJ 7WU4WlUMMs+RtBIo6EmzYA0m26Mv2juofghloj5Ht+eVgl/7yECWrrszw0ALfeFIn/2q 4OnQ== X-Gm-Message-State: ALoCoQl4D5zBiMNqhiwHCu2HVXjaRulUQdkswyidh3Rz2yzRsfHS9S/MV/ZFDclj8o36ZCQTWB1R X-Received: by 10.202.93.4 with SMTP id r4mr24114165oib.92.1434980792669; Mon, 22 Jun 2015 06:46:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.96.167 with HTTP; Mon, 22 Jun 2015 06:46:13 -0700 (PDT) In-Reply-To: References: <1434572241-16019-1-git-send-email-patrick@parcs.ath.cx> <55828A13.8030703@redhat.com> From: Patrick Palka Date: Mon, 22 Jun 2015 13:46:00 -0000 Message-ID: Subject: Re: [PATCH] Test the interaction between GDBHISTSIZE and .gdbinit To: Doug Evans Cc: Pedro Alves , "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-06/txt/msg00439.txt.bz2 On Mon, Jun 22, 2015 at 9:21 AM, Doug Evans wrote: > 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. The env array is "magical" so I'm not sure if these techniques may work on it.