From 0485b56df514b39b488b7d54629f0bd9ab9cdb71 Mon Sep 17 00:00:00 2001 From: Catherine Guelque <66702627+khatharsis42@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:07:54 +0100 Subject: [PATCH] There is no need to install in the global path nor to use SUDO if the given path was writtable (#18) * There's no need for sudo + Added warning if not in PATH * fix: removed duplicated command call --------- Co-authored-by: v4n <105587619+v4n00@users.noreply.github.com> --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index dbfbe23..239f4f6 100755 --- a/install.sh +++ b/install.sh @@ -135,11 +135,17 @@ else fi echo "Installing $SCRIPT_NAME to $DESTINATION_PATH." -sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME" -sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME" +if [ -r "$DESTINATION_PATH" ]; then + curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME" + chmod +x "$DESTINATION_PATH/$SCRIPT_NAME" +else + sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME" + sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME" +fi + if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then - echo -e "${RED}Error:${NC} Installation failed." + echo -e "${RED}Error:${NC} Installation failed. Mod manager was not found in PATH." exit 1 fi