Skip to content

Commit 2aca4e2

Browse files
committed
'main': Make logic more robust. No functional change.
Before this commit, if the value didn't begin with a dollar sign, _zsh_highlight_main_highlighter__try_expand_parameter() would return 1 by accident.¹ Tweak the input validation to make this behaviour explicit. No functional change. ¹ Specifically, it would return 1 because ${parameter_name}'s value would be the empty string and ${parameter_name_pattern} wouldn't match that.
1 parent 7678a8a commit 2aca4e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,12 @@ _zsh_highlight_main_highlighter__try_expand_parameter()
439439
local MATCH; integer MBEGIN MEND
440440
local parameter_name
441441
local -a words
442-
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
442+
if [[ $arg[1] != '$' ]]; then
443+
return 1
444+
fi
445+
if [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
443446
parameter_name=${${arg:2}%?}
444-
elif [[ $arg[1] == '$' ]]; then
447+
else
445448
parameter_name=${arg:1}
446449
fi
447450
if [[ $res == none ]] && zmodload -e zsh/parameter &&

0 commit comments

Comments
 (0)