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

Re: Comprehensive comparison between zsh and bash



On 2019-07-05 at 13:29 -0700, Ray Andrews wrote:
> Just curious:  Is there some way of dumping the state of all variables at
> all lines with both bash and zsh to some file or other such that one could
> quickly spot exactly when and where something might change between them? 
> Not a proactive, analytic study of the code, but just a pragmatic finding of
> differences after the fact.

`typeset -p` dumps all variables; the format differs slightly between
shells but that's light text-munging to normalize.

This is probably a good start:

    trap 'typeset -p' DEBUG

although I'm not going to promise that the DEBUG hook is invoked in
exactly the same circumstances in each shell.  But that should get you
going.  It will be voluminous.

You might consider:

    mkdir -m 0700 -p "$HOME/traces"
    exec 4>"$HOME/traces/$$.log"
    trap 'typeset -p >&4' DEBUG

You could use `set -x` too, to see the commands being run, but while
bash has `BASH_XTRACEFD`, I don't think zsh has anything quite like
that.  So you're going to lose stderr, or accept differences.

-Phil



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