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

Re: setopt temporarily?



On Thursday, February 20, 2014, Phil Pennock <
zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:

> On 2014-02-20 at 13:06 -0800, Dave Yost wrote:
> > It would be nice to be able similarly to temporarily set an option.
>
> Anonymous function.
>
> (){ setopt localoptions xtrace; ls }
>

Also the emulate command:  emulate zsh -o pushdSilent -c 'pushd Desktop'

But in most cases a function with localoptions is what you want.

Incidentally, note that the behavior of
 var=value command
depends on what the command is.  If it's an external command, the variable
is not just temporarily set, it's temporarily exported into the
environment.  For certain builtins the variable becomes permanently set.


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