From 8340ee6ee0c16dc70e201607879cf117daf592f2 Mon Sep 17 00:00:00 2001 From: Stephen Fox Date: Tue, 7 Nov 2023 17:21:57 -0500 Subject: [PATCH 1/2] Add check for TARGET definition before setting, in case user can't get sudo --- install.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 999cb2ec..fe2d1a62 100755 --- a/install.sh +++ b/install.sh @@ -11,15 +11,24 @@ OS="$(uname -s | cut -d '-' -f 1)" case "$OS" in Linux) FILE="${FILE}_linux" - TARGET="/usr/local/bin" + if [ -n "${TARGET+set}" ]; then + echo "TARGET already defined at $TARGET" + else TARGET="/usr/local/bin" + fi ;; Darwin) FILE="${FILE}_darwin" - TARGET="/usr/local/bin" + if [ -n "${TARGET+set}" ]; then + echo "TARGET already defined at $TARGET" + else TARGET="/usr/local/bin" + fi ;; MINGW64_NT) FILE="${FILE}_windows" - TARGET="/c/Windows" + if [ -n "${TARGET+set}" ]; then + echo "TARGET already defined at $TARGET" + else TARGET="/c/Windows" + fi ;; *) echo "Unknown operating system: $OS" @@ -27,6 +36,7 @@ MINGW64_NT) ;; esac + # Include architecture in file name. ARCH="$(uname -m)" case "$ARCH" in From 272072d94c99a97aeb6982b59467a006fa799851 Mon Sep 17 00:00:00 2001 From: Stephen Fox Date: Tue, 7 Nov 2023 17:22:17 -0500 Subject: [PATCH 2/2] Simplify the variable existence evaluation --- install.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index fe2d1a62..ddff124f 100755 --- a/install.sh +++ b/install.sh @@ -11,23 +11,20 @@ OS="$(uname -s | cut -d '-' -f 1)" case "$OS" in Linux) FILE="${FILE}_linux" - if [ -n "${TARGET+set}" ]; then - echo "TARGET already defined at $TARGET" - else TARGET="/usr/local/bin" + if [ ! -n "${TARGET+set}" ]; then + TARGET="/usr/local/bin" fi ;; Darwin) FILE="${FILE}_darwin" - if [ -n "${TARGET+set}" ]; then - echo "TARGET already defined at $TARGET" - else TARGET="/usr/local/bin" + if [ ! -n "${TARGET+set}" ]; then + TARGET="/usr/local/bin" fi ;; MINGW64_NT) FILE="${FILE}_windows" - if [ -n "${TARGET+set}" ]; then - echo "TARGET already defined at $TARGET" - else TARGET="/c/Windows" + if [ ! -n "${TARGET+set}" ]; then + TARGET="/c/Windows" fi ;; *)