Skip to content

Commit

Permalink
driver: Stop requiring function_argzero.
Browse files Browse the repository at this point in the history
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 sorin-ionescu#338.
  • Loading branch information
danielshahaf committed Jun 10, 2016
1 parent d9e07b5 commit 750aebc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions zsh-syntax-highlighting.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0=${(%):-%N}
source ${0:A:h}/zsh-syntax-highlighting.zsh
10 changes: 3 additions & 7 deletions zsh-syntax-highlighting.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

# -------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 750aebc

Please sign in to comment.