[shellcheck] Use `-n/-z` instead of `! -z/! -n` condition

https://github.com/koalaman/shellcheck/wiki/SC2236
Peter Dave Hello 2018-12-03 13:59:19 +08:00 committed by Jordan Harband
parent 153506c8da
commit 14179bc8ce
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
2 changed files with 5 additions and 5 deletions

View File

@ -7,9 +7,9 @@ nvm_has() {
} }
nvm_install_dir() { nvm_install_dir() {
if [ ! -z "$NVM_DIR" ]; then if [ -n "$NVM_DIR" ]; then
printf %s "${NVM_DIR}" printf %s "${NVM_DIR}"
elif [ ! -z "$XDG_CONFIG_HOME" ]; then elif [ -n "$XDG_CONFIG_HOME" ]; then
printf %s "${XDG_CONFIG_HOME/nvm}" printf %s "${XDG_CONFIG_HOME/nvm}"
else else
printf %s "$HOME/.nvm" printf %s "$HOME/.nvm"
@ -123,7 +123,7 @@ install_nvm_from_git() {
fi fi
fi fi
command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)" 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 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 command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
else else
@ -250,7 +250,7 @@ nvm_detect_profile() {
done done
fi fi
if [ ! -z "$DETECTED_PROFILE" ]; then if [ -n "$DETECTED_PROFILE" ]; then
echo "$DETECTED_PROFILE" echo "$DETECTED_PROFILE"
fi fi
} }

2
nvm.sh
View File

@ -323,7 +323,7 @@ nvm_rc_version() {
return 1 return 1
fi fi
NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf '' 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}\"" nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
return 2 return 2
fi fi