From 3f9951902192be04b44ac96c533ffd155b88774b Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Fri, 7 Jul 2017 23:27:18 -0500 Subject: [PATCH] Prefer evaluation over test for arithmetic expression Usage of `(( ... ))` over `[[ ... ]]` is preferred for arithmetic expression since the former is less error prone. Also, unset local variable whenever possible. --- CONTRIBUTING.md | 1 + modules/completion/init.zsh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 377e6f0..7800b81 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,7 @@ there are a number of additional things to keep in mind. - Local variables should be used whenever possible. - Prefer `zstyle` over environment variables for configuration. + - Prefer (( ... )) over [[ ... ]] for arithmetic expression. - Use the function keyword to define functions. - The 80 character hard limit can be waved for readability. diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 912c586..8b7634a 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -32,12 +32,13 @@ unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. # cache time of 20 hours, so it should almost always regenerate the first time a # shell is opened each day. autoload -Uz compinit -compfiles=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20)) -if [[ $#compfiles > 0 ]]; then +_comp_files=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20)) +if (( $#_comp_files )); then compinit -i -C else compinit -i fi +unset _comp_files # # Styles