From 750aebc553f2f4149055ef4cb9d7641f5df6d3ea Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 10 Jun 2016 15:09:45 +0000 Subject: [PATCH] driver: Stop requiring function_argzero. Instead, use the %N prompt expando, as suggested by Bart in users/21637. Avoid the `print -P %N` syntax to save a fork on Cygwin, at the expense of not supporting zsh's from 2001 through c. 2004 vintages. Fixes #338. --- zsh-syntax-highlighting.plugin.zsh | 1 + zsh-syntax-highlighting.zsh | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/zsh-syntax-highlighting.plugin.zsh b/zsh-syntax-highlighting.plugin.zsh index 2fa8b3b..f2456ae 100644 --- a/zsh-syntax-highlighting.plugin.zsh +++ b/zsh-syntax-highlighting.plugin.zsh @@ -1 +1,2 @@ +0=${(%):-%N} source ${0:A:h}/zsh-syntax-highlighting.zsh diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 5ba8695..87967b6 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -28,7 +28,9 @@ # ------------------------------------------------------------------------------------------------- -if [[ -o function_argzero ]]; then +# Set $0 to the expected value, regardless of functionargzero. +0=${(%):-%N} +if true; then # $0 is reliable ZSH_HIGHLIGHT_VERSION=$(<"${0:A:h}"/.version) ZSH_HIGHLIGHT_REVISION=$(<"${0:A:h}"/.revision-hash) @@ -38,12 +40,6 @@ if [[ -o function_argzero ]]; then # the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so: ZSH_HIGHLIGHT_REVISION=HEAD fi -else - # $0 is unreliable, so the call to _zsh_highlight_load_highlighters will fail. - # TODO: If 'zmodload zsh/parameter' is available, ${funcsourcetrace[1]%:*} might serve as a substitute? - # TODO: also check POSIX_ARGZERO, but note it's not available in older zsh - echo "zsh-syntax-highlighting: error: not compatible with NO_FUNCTION_ARGZERO" >&2 - return 1 fi # -------------------------------------------------------------------------------------------------