From 14179bc8cede48ee6d66ec07a9d088ed39886b5b Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 3 Dec 2018 13:59:19 +0800 Subject: [PATCH] [shellcheck] Use `-n/-z` instead of `! -z/! -n` condition https://github.com/koalaman/shellcheck/wiki/SC2236 --- install.sh | 8 ++++---- nvm.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 799dbe2..ce43685 100755 --- a/install.sh +++ b/install.sh @@ -7,9 +7,9 @@ nvm_has() { } nvm_install_dir() { - if [ ! -z "$NVM_DIR" ]; then + if [ -n "$NVM_DIR" ]; then printf %s "${NVM_DIR}" - elif [ ! -z "$XDG_CONFIG_HOME" ]; then + elif [ -n "$XDG_CONFIG_HOME" ]; then printf %s "${XDG_CONFIG_HOME/nvm}" else printf %s "$HOME/.nvm" @@ -123,7 +123,7 @@ install_nvm_from_git() { fi fi command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)" - if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then + if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 else @@ -250,7 +250,7 @@ nvm_detect_profile() { done fi - if [ ! -z "$DETECTED_PROFILE" ]; then + if [ -n "$DETECTED_PROFILE" ]; then echo "$DETECTED_PROFILE" fi } diff --git a/nvm.sh b/nvm.sh index 4db973c..b0df452 100644 --- a/nvm.sh +++ b/nvm.sh @@ -323,7 +323,7 @@ nvm_rc_version() { return 1 fi NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf '' - if [ ! -n "${NVM_RC_VERSION}" ]; then + if [ -z "${NVM_RC_VERSION}" ]; then nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\"" return 2 fi