From 60172991e35eb0ccf3f0884597054464c93d0abd Mon Sep 17 00:00:00 2001 From: Manish Tiwari Date: Thu, 20 Aug 2026 10:36:01 +0530 Subject: [PATCH 1/2] 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. --- changelog.md | 5 +++++ zsh-syntax-highlighting.zsh | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) 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..cc02f9f 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 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 From 49fa220757b56de8b8a6d2b465ac9a44dd0aa5b3 Mon Sep 17 00:00:00 2001 From: Manish Tiwari Date: Thu, 20 Aug 2026 11:08:08 +0530 Subject: [PATCH 2/2] Clarify alias-restoration comment wording Per review feedback on #985: "we unned" was unclear/informal. --- zsh-syntax-highlighting.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index cc02f9f..0c9df9b 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -579,7 +579,7 @@ if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST fi -# Restore the aliases we unned. +# 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