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

Regarding emulate: a thought, and refresh my memory?



First the memory bump:

The code in bin_emulate dating all the way back to Andrej's patch in
zsh-workers/26425 rejects the combination of -L and -c.  The stated
reason for this is "do not confuse user who reads manuals."  However,
the -c option always restores everything at the end, and anyway one
can always run
    emulate zsh -c 'setopt localoptions; ...'
so I'm hoping someone can remind me why we bother throwing an error
on that combination.

The reason I ask is because it suddenly popped into my head that the
emulate command might just as well parse other startup-time options
besides just -c.  Primarily this means that instead of e.g.

    emulate zsh -c 'setopt xtrace; blah blah blah ...'

one could simply do

    emulate zsh -x -c 'blah blah blah ...'

Simlarly there are all sorts of functions that begin with stuff like

    emulate -R zsh
    setopt extendedglob

which could become

    emulate -R zsh -o extendedglob

and off you go.

I've got this 98% working by factoring a loop out of init.c:parseargs()
but it seems silly that
    emulate -L zsh -c '...'
throws an error when
    emulate zsh --localoptions -c '...'
does not.  (Of course -L means a bit more than --localoptions, but you
see my point, I hope.)



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