From 6a6d40208cd96024e5d23eb7452804f6bf696304 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sat, 25 Nov 2017 15:16:20 -0600 Subject: [PATCH] main: Add fallback for useroptions if zsh/parameter is absent --- highlighters/main/main-highlighter.zsh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 1343d6a..50415d8 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -196,7 +196,21 @@ _zsh_highlight_main__stack_pop() { _zsh_highlight_highlighter_main_paint() { # Before we even 'emulate -L', save the user's options - local -A useroptions; useroptions=("${(@kv)options}") + local -A useroptions + if zmodload -e zsh/parameter; then + useroptions=("${(@kv)options}") + else + local canonicaloptions onoff option rawoptions + rawoptions=(${(f)"$(emulate -R zsh; set -o)"}) + canonicaloptions=(${${${(M)rawoptions:#*off}%% *}#no} ${${(M)rawoptions:#*on}%% *}) + for option in $canonicaloptions; do + [[ -o $option ]] + # This variable cannot be eliminated c.f. workers/42101. + onoff=${${=:-off on}[2-$?]} + useroptions+=($option $onoff) + done + fi + emulate -L zsh setopt localoptions extendedglob bareglobqual