diff --git a/install.sh b/install.sh index 7a36660..af4f8b6 100755 --- a/install.sh +++ b/install.sh @@ -190,6 +190,15 @@ main() { esac done + # A quoted --dir "~/bin" or IDX_INSTALL_DIR="~/bin" reaches us unexpanded. + # shellcheck disable=SC2088 # matching a literal, unexpanded ~ on purpose + case "$install_dir" in + "~") install_dir="$HOME" ;; + "~/"*) install_dir="$HOME/${install_dir#"~/"}" ;; + esac + github_url="${github_url%/}" + api_url="${api_url%/}" + asset="$(detect_asset)" tmp_dir="$(mktemp -d 2>/dev/null || mktemp -d -t idx-install)" diff --git a/scripts/install-sh-test.sh b/scripts/install-sh-test.sh index 6e613a4..b4ab006 100755 --- a/scripts/install-sh-test.sh +++ b/scripts/install-sh-test.sh @@ -178,6 +178,18 @@ else fail "replaces an existing install cleanly"; cat "${work}/out8" >&2 fi +# 9. quoted ~ in --dir expands to HOME; trailing slash on mirror URLs is fine. +# shellcheck disable=SC2088 # the literal ~ is the input under test +if env IDX_GITHUB_URL="http://127.0.0.1:${port}/gh/" \ + IDX_GITHUB_API="http://127.0.0.1:${port}/api/" \ + HOME="${work}/home" \ + "$test_shell" "$installer" --dir "~/tilde-bin" >"${work}/out9" 2>&1 && + [[ -x "${work}/home/tilde-bin/idx" ]]; then + pass "expands quoted ~ and tolerates trailing slashes" +else + fail "expands quoted ~ and tolerates trailing slashes"; cat "${work}/out9" >&2 +fi + if ((failures > 0)); then echo "install.sh tests: ${failures} failure(s) with ${test_shell}" >&2 exit 1