From 73850e5537630507d3a07604731716f8f8ef73b4 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 16 Mar 2020 18:08:56 +0800 Subject: [PATCH] Quote "${TFENV_ROOT}" argument in all `[ -n ]` Reference: https://github.com/koalaman/shellcheck/wiki/SC2070 ``` [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; ^-----------^ SC2070: -n doesn't work with unquoted arguments. Quote or use [[ ]]. ``` --- libexec/tfenv---version | 2 +- libexec/tfenv-exec | 2 +- libexec/tfenv-install | 2 +- libexec/tfenv-list | 2 +- libexec/tfenv-list-remote | 2 +- libexec/tfenv-min-required | 2 +- libexec/tfenv-resolve-version | 2 +- libexec/tfenv-uninstall | 2 +- libexec/tfenv-use | 2 +- libexec/tfenv-version-file | 2 +- libexec/tfenv-version-name | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libexec/tfenv---version b/libexec/tfenv---version index 6bc8e28..2e819ac 100755 --- a/libexec/tfenv---version +++ b/libexec/tfenv---version @@ -36,7 +36,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-exec b/libexec/tfenv-exec index 6ebcb04..975e5b2 100755 --- a/libexec/tfenv-exec +++ b/libexec/tfenv-exec @@ -40,7 +40,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-install b/libexec/tfenv-install index 781a92b..f05f925 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -26,7 +26,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-list b/libexec/tfenv-list index b8e232a..d9913b3 100755 --- a/libexec/tfenv-list +++ b/libexec/tfenv-list @@ -27,7 +27,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-list-remote b/libexec/tfenv-list-remote index 8b04997..ff99959 100755 --- a/libexec/tfenv-list-remote +++ b/libexec/tfenv-list-remote @@ -27,7 +27,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-min-required b/libexec/tfenv-min-required index b886e93..1399856 100755 --- a/libexec/tfenv-min-required +++ b/libexec/tfenv-min-required @@ -29,7 +29,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-resolve-version b/libexec/tfenv-resolve-version index d488e52..e6c54e5 100755 --- a/libexec/tfenv-resolve-version +++ b/libexec/tfenv-resolve-version @@ -29,7 +29,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-uninstall b/libexec/tfenv-uninstall index 19a506e..5e811af 100755 --- a/libexec/tfenv-uninstall +++ b/libexec/tfenv-uninstall @@ -27,7 +27,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-use b/libexec/tfenv-use index 2a96a2d..33817d3 100755 --- a/libexec/tfenv-use +++ b/libexec/tfenv-use @@ -26,7 +26,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-version-file b/libexec/tfenv-version-file index e4f0ce7..6b9697a 100755 --- a/libexec/tfenv-version-file +++ b/libexec/tfenv-version-file @@ -29,7 +29,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi; diff --git a/libexec/tfenv-version-name b/libexec/tfenv-version-name index d9bbe5d..b8923c4 100755 --- a/libexec/tfenv-version-name +++ b/libexec/tfenv-version-name @@ -28,7 +28,7 @@ if [ -z "${TFENV_ROOT:-""}" ]; then }; TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; - [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; + [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else TFENV_ROOT="${TFENV_ROOT%/}"; fi;