diff --git a/changelog.md b/changelog.md index 8ee5088..6879db5 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 4295c93..0c9df9b 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -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 that were unaliased above (via 'builtin unalias'). +# +# 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