This will break calls to zsh-defer with flags. It can also be very confusing because readers who will see zsh-defer being called somewhere will incorrectly assume that zsh-defer actually gets called.
If you want conditional deferral, it's better to use something like this:
function run-or-defer() {
emulate -L zsh -o extended_glob
if [[ -o interactive && $DISABLE_DEFER == (#i)(|0|no|false) ]]; then
zsh-defer -- "$@"
else
"$@"
fi
}
Then use run-or-defer when you want conditional deferral, zsh-defer when you want deferral, and plain commands when you want immediate execution.
I don't think either version would be a net positive contribution to the documentation, so I'll close the PR.
This will break calls to
zsh-defer
with flags. It can also be very confusing because readers who will seezsh-defer
being called somewhere will incorrectly assume thatzsh-defer
actually gets called.If you want conditional deferral, it's better to use something like this:
Then use
run-or-defer
when you want conditional deferral,zsh-defer
when you want deferral, and plain commands when you want immediate execution.I don't think either version would be a net positive contribution to the documentation, so I'll close the PR.