From ddb4f1c8f8653f4c579f0a8da783f4a1eff20761 Mon Sep 17 00:00:00 2001 From: Peng Ding Date: Mon, 20 Jan 2025 05:38:50 -0600 Subject: [PATCH] fix compatibility issue with sh. --- supplemental/scripts/install-agent.sh | 9 ++++++--- supplemental/scripts/install-hub.sh | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/supplemental/scripts/install-agent.sh b/supplemental/scripts/install-agent.sh index c654cea..f9caa4e 100755 --- a/supplemental/scripts/install-agent.sh +++ b/supplemental/scripts/install-agent.sh @@ -10,8 +10,11 @@ is_openwrt() { # Function to ensure the proxy URL ends with a / ensure_trailing_slash() { - if [ -n "$1" ] && [ "${1: -1}" != "/" ]; then - echo "$1/" + if [ -n "$1" ]; then + case "$1" in + */) echo "$1" ;; + *) echo "$1/" ;; + esac else echo "$1" fi @@ -23,7 +26,7 @@ UNINSTALL=false CHINA_MAINLAND=false GITHUB_URL="https://github.com" GITHUB_API_URL="https://api.github.com" -GITHUB_PROXY_URL="https://ghfast.top/" # Default proxy URL +GITHUB_PROXY_URL="https://ghfast.top/" # Default proxy URL KEY="" # Check for help flag first diff --git a/supplemental/scripts/install-hub.sh b/supplemental/scripts/install-hub.sh index 7df1727..eb71655 100755 --- a/supplemental/scripts/install-hub.sh +++ b/supplemental/scripts/install-hub.sh @@ -19,8 +19,11 @@ GITHUB_PROXY_URL="https://ghfast.top/" # Default proxy URL # Function to ensure the proxy URL ends with a / ensure_trailing_slash() { - if [ -n "$1" ] && [ "${1: -1}" != "/" ]; then - echo "$1/" + if [ -n "$1" ]; then + case "$1" in + */) echo "$1" ;; + *) echo "$1/" ;; + esac else echo "$1" fi