diff options
author | Marc Cornellà <hello@mcornella.com> | 2022-03-07 11:13:18 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-03-07 11:13:18 +0100 |
commit | 9350e1ff8724341534a8def2ce76ede88a4c2868 (patch) | |
tree | 941cf7e75d4273c7a2f2f08f562bc875f58fda7d /plugins/coffee | |
parent | 93b348b172506be46000f3be1cebda76d4c71999 (diff) | |
download | zsh-9350e1ff8724341534a8def2ce76ede88a4c2868.tar.gz zsh-9350e1ff8724341534a8def2ce76ede88a4c2868.tar.bz2 zsh-9350e1ff8724341534a8def2ce76ede88a4c2868.zip |
fix(coffee): fix completion bug on missing `coffee` command (#10759)
This commit fixes the error
_coffee:49: bad math expression: operand expected at `< 2 '
when the coffee command is missing or the `coffee --version` command fails.
It also uses is-at-least to check for the cut-off version for suggesting
`--lint` and `--require` arguments, instead of using `cut` multiple times.
Fixes #10759
Diffstat (limited to 'plugins/coffee')
-rw-r--r-- | plugins/coffee/_coffee | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/coffee/_coffee b/plugins/coffee/_coffee index 5e52b30e6..e2814f7ba 100644 --- a/plugins/coffee/_coffee +++ b/plugins/coffee/_coffee @@ -39,14 +39,14 @@ # # ------------------------------------------------------------------------------ -local curcontext="$curcontext" state line ret=1 version opts first second third +local curcontext="$curcontext" state line ret=1 version +local -a opts typeset -A opt_args -version=(${(f)"$(_call_program version $words[1] --version)"}) +version=(${(f)"$(_call_program version $words[1] --version)"}) || return ret version=${${(z)${version[1]}}[3]} -first=$(echo $version|cut -d '.' -f 1) -second=$(echo $version|cut -d '.' -f 2) -third=$(echo $version|cut -d '.' -f 3) -if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then + +autoload -Uz is-at-least +if ! is-at-least 1.6.3 "$version"; then opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' '(-r --require)'{-r,--require}'[require a library before executing your script]:library') fi |