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

Re: Disabling an option for a single statement



On Mon, Aug 22, 2022 at 10:46 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> It's not uncommon that I want to disable a specific option (in my case, cdablevars) for a single statement.

There's not really a better way in general.  There are of course the
noglob and nocorrect "precommand modifiers" which have this effect for
the GLOB and CORRECT options, but it's not generalized.

You can sort of make it work with something like

alias nocdv='() { setopt localoptions nocdablevars; "$@" } '

but that doesn't affect things that happen during argument
interpretation, such as potentially ${(D)var}, so there are several
options for which using an alias is not very helpful.




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