From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103175 invoked by alias); 22 Jun 2015 13:59:05 -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 103162 invoked by uid 89); 22 Jun 2015 13:59:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00,KAM_TK,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 22 Jun 2015 13:59:03 +0000 Received: by obctg8 with SMTP id tg8so113578600obc.3 for ; Mon, 22 Jun 2015 06:59:01 -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=S+m7MJX255TkOLb16qjLkTLdpT5dA2+nanngzfOz4Ug=; b=GfrzBMvSgcYryf3WO5FSXG+IAoJGqsKBX1uTtnr4A13mNJSJJ/jYjg7T5hdEiA9FIt p2QuMqesXowJwBvV7FFYxC1nmGRELkTCJWBg348KRpJ9cnFS5VyCtzqdkgCyygPF7xfY krX5evYbkNXqx4PM5idmpvOV2nua7GpEftq/2lCS0LQIKCcukOLbBLDUCaJWBKiYGKrL +KF1sJoPDtvKj2AeyW9694kce59zELuafTtCc6SrpQWTPWUwq+SJnCoDqwQSdU8dgJzz 5jY3IV+EMj/6C2OxU3u8VmaxhaNRmcdmmXp/CWZb19q0Tkc0K5TTqgY9OcFSxYVCqm4H Ma2w== X-Gm-Message-State: ALoCoQnSBO4eRgmn9JzLIN5RjEd7iVf4EL6Exmvj+Bjv4JTMQDD0B2+11sv+H5wkCiaiZIEg1rVY MIME-Version: 1.0 X-Received: by 10.60.147.194 with SMTP id tm2mr25076634oeb.75.1434981541609; Mon, 22 Jun 2015 06:59:01 -0700 (PDT) Received: by 10.182.89.99 with HTTP; Mon, 22 Jun 2015 06:59:01 -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:59: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/msg00440.txt.bz2 On Mon, Jun 22, 2015 at 8:46 AM, Patrick Palka wrote: > 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. 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.