Skip to content

Commit

Permalink
'main': Fix regression in zsh 5.3.1 and older: all precmd hooks later…
Browse files Browse the repository at this point in the history
… than z-sy-h would be aborted.

In those versions of zsh, «[[ -o nosuchoption ]]» is regarded as
a syntax error.  In newer zsh versions, it merely returns non-zero
(specifically, it returns 3, unlike «[[ -o unsetoption ]]» which
returns 1).

Fixes #732.
Fixes #733.
  • Loading branch information
danielshahaf committed May 6, 2020
1 parent 0582ea1 commit 3a4b212
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

- Fix an error message on stderr before every prompt when the `WARN_NESTED_VAR` zsh option is set:
`_zsh_highlight_main__precmd_hook:1: array parameter _zsh_highlight_main__command_type_cache set in enclosing scope in function _zsh_highlight_main__precmd_hook`
[#727, #731]
[#727, #731, #732, #733]

# Changes in version 0.7.1

Expand Down
2 changes: 1 addition & 1 deletion highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ _zsh_highlight_main__precmd_hook() {
# Unset the WARN_NESTED_VAR option, taking care not to error if the option
# doesn't exist (zsh older than zsh-5.3.1-test-2).
setopt localoptions
if [[ -o warnnestedvar ]] 2>/dev/null; then
if eval '[[ -o warnnestedvar ]]' 2>/dev/null; then
unsetopt warnnestedvar
fi

Expand Down

0 comments on commit 3a4b212

Please sign in to comment.