zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: following a variable's value.
Date: Sun, 18 Oct 2015 09:54:41 -0700	[thread overview]
Message-ID: <CAH+w=7ZaMhmY9CLW5JrnB8=5bXxx5JGATG9o7WQVLBCpZ_prVg@mail.gmail.com> (raw)
In-Reply-To: <5622DC5B.20103@eastlink.ca>

On Sat, Oct 17, 2015 at 4:40 PM, Ray Andrews <rayandrews@eastlink.ca> 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.


      parent reply	other threads:[~2015-10-18 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-17 23:40 Ray Andrews
2015-10-18  0:29 ` ZyX
2015-10-18  4:31   ` Ray Andrews
2015-10-18 11:19     ` ZyX
2015-10-18 17:15       ` Ray Andrews
2015-10-18 17:33         ` Bart Schaefer
2015-10-18 17:46           ` Ray Andrews
2015-10-18 16:54 ` Bart Schaefer [this message]

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='CAH+w=7ZaMhmY9CLW5JrnB8=5bXxx5JGATG9o7WQVLBCpZ_prVg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).