Restore aliases via 'builtin' consistently

Aliases were unaliased defensively with 'builtin unalias' before this
script runs, but restored afterwards via a plain 'eval "$aliases"',
which calls 'alias' rather than 'builtin alias'. If the user had
aliased or otherwise overridden 'alias' itself, the script would wipe
out their aliases and then silently fail to restore them.

Fixes #972.
This commit is contained in:
Manish Tiwari 2026-08-20 10:36:01 +05:30
parent c4d9559184
commit 60172991e3
2 changed files with 15 additions and 3 deletions

View File

@ -4,6 +4,11 @@
- Highlight `&>` `>&|` `>&!` `&>|` and `&>!` as redirection.
[#942]
- Fixed: aliases were restored via a plain (non-`builtin`) call to `alias`,
so if the user had overridden/aliased `alias` itself, restoration could
fail silently.
[#972]
# Changes in 0.8.0

View File

@ -579,9 +579,16 @@ if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
fi
# Restore the aliases we unned
eval "$zsh_highlight__aliases"
builtin unset zsh_highlight__aliases
# Restore the aliases we unned.
#
# We use 'builtin' here (and not just when capturing them above) in case the
# 'alias' command has itself been aliased or overridden by the user; see
# issue #972.
typeset zsh_highlight__alias
for zsh_highlight__alias in ${(f)zsh_highlight__aliases}; do
eval "builtin $zsh_highlight__alias"
done
builtin unset zsh_highlight__aliases zsh_highlight__alias
# Set $?.
true