Skip to content

Commit

Permalink
fix: Don't error if $OPTS is not yet defined in .zinit-compinit call
Browse files Browse the repository at this point in the history
This codepath was triggered when deleting the whole `~/.zinit/plugins` dir: during recreation in `.zinit-prepare-home`, `.zinit-compinit &> /dev/null` would be called and the sourcing of `zinit.zsh` would error out with

```
+.zinit-compinit:2> [[.zinit-compinit:2: bad math expression: operand expected at `/Users/jan...'
 -n '' ]]
```

As the error was redirected to `/dev/null`, this never showed up. Any zinit install call during that session would not run any hooks as they were not yet registered. The next session would then be fine because the plugins dir would exist.
  • Loading branch information
jankatins committed May 1, 2022
1 parent 49af866 commit 44765e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zinit-install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
#
# No arguments.
.zinit-compinit() {
[[ -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return
# This might be called during sourcing when setting up the plugins dir, so check that OPTS is actually existing
[[ -n $OPTS && -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return

emulate -LR zsh
builtin setopt nullglob extendedglob warncreateglobal typesetsilent
Expand Down

0 comments on commit 44765e0

Please sign in to comment.