Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: following a variable's value.
- X-seq: zsh-users 20785
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: following a variable's value.
- Date: Sun, 18 Oct 2015 03:29:11 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1445128152; bh=mVepNFxFQEJmewMEWO8g6mzxDUpo5+8NDzVVmpCfLE0=; h=From:To:In-Reply-To:References:Subject:Date; b=jCKHe0Fi9YClXPGD8tWueOrKUbIB/OQjGmnc4dtsWNYgr3T3mq5THQnPNB0Jbma9v yk7ItK5QHYbfo1S72NzayA+h8AboI0zPnEcCPb95DnMF1nVCq+xCxWtpON1YtLYg5U 9mUZOiIEpudmFovsvFrfL15bh0CSSnjK25VCYWvA=
- In-reply-to: <5622DC5B.20103@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <5622DC5B.20103@eastlink.ca>
18.10.2015, 03:11, "Ray Andrews" <rayandrews@xxxxxxxxxxx>:
> 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.
I personally know only one way: create a C module which will create a special variable which will run some method each time variable is assigned. Partially you can do it with my https://bitbucket.org/ZyX_I/zpython, but this is rather limited:
1. You are bound to a single variable type. Type can be any: integer, float, string, array, associative array, but only one. Type may only be changed by unsetting the variable and creating a new one.
2. Variable name must start with a $zpython_.
3. Setting non-hash variables is using rather strange convention: zpython_string=foo will call `{bound_object}.__call__('foo')` (essentially the same thing as `{bound_object}('foo')`). This is because normally such types are immutable (hashes can be mutated in-place and zpython uses corresponding methods in place of `__call__`). Do not remember why I choosed not to use standard sequence protocol for editing arrays in addition to hashes, some of which may also be mutated (like list() type).
Also I am not really sure whether calling zsh code from parameter handlers is a safe operation, as well as querying any specific operation.
If you write C module specifically for your needs you may overcome these limitations.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author