From 2dce602727d715f142b5067be4f85de84d98a8b7 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 11 Nov 2016 08:34:46 +0000 Subject: [PATCH] driver: Be immune to weird aliases in the calling scope. Fixes #390. --- zsh-syntax-highlighting.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index ec01306..b1e3fbb 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -27,6 +27,9 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +# First of all, ensure predictable parsing. +zsh_highlight__aliases=`alias -L` +builtin unalias -m '*' # Set $0 to the expected value, regardless of functionargzero. 0=${(%):-%N} @@ -390,4 +393,11 @@ zmodload zsh/parameter 2>/dev/null || true autoload -U is-at-least # Initialize the array of active highlighters if needed. -[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true +[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) + +# Restore the aliases we unned +eval "$zsh_highlight__aliases" +builtin unset zsh_highlight__aliases + +# Set $?. +true