Skip to content

Commit 9c56c62

Browse files
committed
versionstamp: Handle NO_FUNCTION_ARGZERO.
Sourcing zsh-syntax-highlighting.zsh without FUNCTION_ARGZERO doesn't work (for reasons unrelated to this branch), but now errors out gracefully. The failure mode before this branch was: zsh-syntax-highlighting: highlighters directory '/usr/local/bin/highlighters' not found. where /usr/local/bin is dirname() of the zsh binary.
1 parent 4338637 commit 9c56c62

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

zsh-syntax-highlighting.zsh

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929
# -------------------------------------------------------------------------------------------------
3030

3131

32-
ZSH_HIGHLIGHT_VERSION=$(<"$0:h"/.version)
32+
if [[ -o function_argzero ]]; then
33+
# $0 is reliable
34+
ZSH_HIGHLIGHT_VERSION=$(<"$0:h"/.version)
35+
else
36+
# $0 is unreliable, so the call to _zsh_highlight_load_highlighters will fail.
37+
# TODO: If 'zmodload zsh/parameter' is available, ${funcsourcetrace[1]%:*} might serve as a substitute?
38+
# TODO: also check POSIX_ARGZERO, but not it's not available in older zsh
39+
echo "zsh-syntax-highlighting: error: not compatible with FUNCTION_ARGZERO" >&2
40+
return 1
41+
fi
3342

3443
# -------------------------------------------------------------------------------------------------
3544
# Core highlighting update system

0 commit comments

Comments
 (0)