avoid errors unbound variables and unset parameters (#50)

zsh prints an abundance of errors when `setopt nounset` is enabled and
fast-syntax-highlighting is activated (#49). This commit helps to avoid
the unnecessary verbosity.

Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
This commit is contained in:
Lucas Larson
2023-03-24 23:06:05 +01:00
committed by GitHub
parent 5521b083f8
commit 371591a7b6
+5 -5
View File
@@ -45,13 +45,13 @@ typeset -ga _FAST_MAIN_CACHE
typeset -ga _FAST_COMPLEX_BRACKETS
typeset -g FAST_WORK_DIR=${FAST_WORK_DIR:-${XDG_CACHE_HOME:-~/.cache}/fast-syntax-highlighting}
: ${FAST_WORK_DIR:=$FAST_BASE_DIR}
: ${FAST_WORK_DIR:=${FAST_BASE_DIR-}}
# Expand any tilde in the (supposed) path.
FAST_WORK_DIR=${~FAST_WORK_DIR}
# Last (currently, possibly) loaded plugin isn't "fast-syntax-highlighting"?
# And FPATH isn't containing plugin dir?
if [[ ${zsh_loaded_plugins[-1]} != */fast-syntax-highlighting && -z ${fpath[(r)${0:h}]} ]]
if [[ ${zsh_loaded_plugins[-1]-} != */fast-syntax-highlighting && -z ${fpath[(r)${0:h}]-} ]]
then
fpath+=( "${0:h}" )
fi
@@ -252,7 +252,7 @@ _zsh_highlight_bind_widgets()
local cur_widget
for cur_widget in $widgets_to_bind; do
case $widgets[$cur_widget] in
case ${widgets[$cur_widget]-} in
# Already rebound event: do nothing.
user:_zsh_highlight_widget_*);;
@@ -279,7 +279,7 @@ _zsh_highlight_bind_widgets()
# Incomplete or nonexistent widget: Bind to z-sy-h directly.
*)
if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
if [[ $cur_widget == zle-* ]] && [[ -z ${widgets[$cur_widget]-} ]]; then
_zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
zle -N -- $cur_widget _zsh_highlight_widget_$cur_widget
else
@@ -381,4 +381,4 @@ if [[ $(uname -a) = (#i)*darwin* ]] {
FAST_HIGHLIGHT[chroma-man]=
}
[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null || true
[[ ${COLORTERM-} == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null || true