From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25180 invoked by alias); 18 Oct 2015 16:54:45 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20789 Received: (qmail 10043 invoked from network); 18 Oct 2015 16:54:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 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=Ns04LoxOKf+DY2RzW9MlmZEwLUdWhgDcRVvI8g0xiPw=; b=jg8/snLgraB5O5mYNtD+YpVVM1jk2T4+ZNF0cpCG8tMMaQMZr/9KZMzmDvvr4+r16S TViHRmucZpFwQLyM7MIl8BfNiLXBb8o17AmrkEzOV/eEDKv5ceKkllEBSP0+3S+hlJms 2Eye6LjJ1tjBx4M1lmTokggwAS2L5nwd5vWxvAlwWF6wJKxFlEad1ezP30Xzoa7m3xsF fbkGz3GE6AZdW9gyLhaFgcY094MnCLPSTx4ACffrQD2AJQoLOpVK+I2rgphqVixDFYgy gEzrf8gCHlFKOuY0SKf3j0m/xtbUQB+E+l2/20hSjdq0rGT2zupMf4W0ioxbBdrQur5i RvDQ== X-Gm-Message-State: ALoCoQkuKxI+iQqVwPS1axwZYbjGDHFF4A3c3sJwKVGbpiGNRYFXr9IJ0YIfV7Jxt48p8VC7Fg7o MIME-Version: 1.0 X-Received: by 10.194.110.4 with SMTP id hw4mr28470174wjb.135.1445187281805; Sun, 18 Oct 2015 09:54:41 -0700 (PDT) In-Reply-To: <5622DC5B.20103@eastlink.ca> References: <5622DC5B.20103@eastlink.ca> Date: Sun, 18 Oct 2015 09:54:41 -0700 Message-ID: Subject: Re: following a variable's value. From: Bart Schaefer To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 On Sat, Oct 17, 2015 at 4:40 PM, Ray Andrews wrote: > Gentlemen, > > I discovered by accident the useful 'warncreateglobal' and it has me in mind > to ask if there's some way of tracing the value of variable. I know about > 'set -x' of course, but some way of following the fortunes of a single > variable would be very nice. Take a look at traps for the DEBUG pseudo-signal. The simplest formulation might look something like this: unsetopt debug_before_cmd typeset -ga var_watchlist TRAPDEBUG() { (( $#var_watchlist )) && typeset -m "${var_watchlist[@]}" } Now after every command you'll see the value of whatever variables are named in $var_watchlist. Left as an exercise is to store the current value somewhere and only print the new value when it changes. Once you've done that, then it should further be easy to print something when the variable becomes unset.