Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Should (t)path = array-unique-special work this way



On 14 February 2016 at 19:44, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author