Subject: Re: Should (t)path = array-unique-special work this way
From: Sebastian Gniazdowski <[email-masked]>
To: Bart Schaefer <[email-masked]>
Cc: Zsh hackers list <[email-masked]>
Date: Mon, 15 Feb 2016 09:25:41 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On 14 February 2016 at 19:44, Bart Schaefer <[email-masked]> wrote:
> On Feb 14, 11:04am, Sebastian Gniazdowski wrote:
> }
> } Wanted to write a snapshot feature, basically declare -p > snapshot;
> } setopt typesetsilent; source ./snapshot, but the omission of -U is
> } quite a blocker.
>
> This doesn't work in the general case anyway, because the output of
> "typeset -p" (aka "declare -p") doesn't properly reflect local scopes.
> That is, if you're in a local scope, sourcing the "declare -p" output
> will create all the variables at that local scope, not at the scopes
> where they were originally defined.
>
> In fact it's impossible to correctly reconstruct the local and global
> scopes because of the runtime dynamic scoping rules.

Assuming the feature is for interactive use, what can be the issues
with scopes? I started a new project, worked around limitations of
declare -p with $parameters:

https://github.com/psprint/zsnapshot

It is called in current scope via alias zsnapshot="source snapshot >
snap", the user is informed that he should source output file at
prompt. Are there any possible issues?

(Started this project to face dirt that e.g. a theme can introduce
into session. Before trying a theme that messes up with precmd() and
PS1, one calls snapshot so that he can revert)

Best regards,
Sebastian Gniazdowski