Skip to content

Commit 497c8f1

Browse files
committed
refactor: refactor variable initialization for client configuration
- Move CLIENT_PLATFORM, CLIENT_ARCH, and CURL_INSECURE variable initialization to the top-level scope - Remove their redundant initialization from detect_client_info and download_and_install functions Signed-off-by: appleboy <[email protected]>
1 parent 974c7d2 commit 497c8f1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

install.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ NC='\033[0m' # No Color
1313
RELEASE_URL="${RELEASE_URL:-https://github.com/appleboy/CodeGPT/releases/download}"
1414
VERSION="${VERSION:-0.16.1}"
1515
INSTALL_DIR="${INSTALL_DIR:-$HOME/.codegpt/bin}"
16+
CURL_INSECURE="${CURL_INSECURE:-false}"
17+
CLIENT_PLATFORM="${SSH_CLIENT_OS:-$(uname -s | tr '[:upper:]' '[:lower:]')}"
18+
CLIENT_ARCH="${SSH_CLIENT_ARCH:-$(uname -m)}"
1619

1720
function print_message() {
1821
local level=$1
@@ -34,9 +37,6 @@ function log_error() {
3437
}
3538

3639
function detect_client_info() {
37-
CLIENT_PLATFORM="${SSH_CLIENT_OS:-$(uname -s | tr '[:upper:]' '[:lower:]')}"
38-
CLIENT_ARCH="${SSH_CLIENT_ARCH:-$(uname -m)}"
39-
4040
case "${CLIENT_PLATFORM}" in
4141
darwin | linux | windows) ;;
4242
*) log_error "Unknown or unsupported platform: ${CLIENT_PLATFORM}. Supported platforms are Linux, Darwin, and Windows." 2 ;;
@@ -56,7 +56,6 @@ function download_and_install() {
5656
CLIENT_BINARY="CodeGPT-${VERSION}-${CLIENT_PLATFORM}-${CLIENT_ARCH}"
5757
print_message info "Downloading ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX}"
5858

59-
CURL_INSECURE="${CURL_INSECURE:-false}"
6059
if [[ "${CURL_INSECURE}" != 'true' && "${CURL_INSECURE}" != 'false' ]]; then
6160
log_error "CURL_INSECURE must be either 'true' or 'false'" 4
6261
fi

0 commit comments

Comments
 (0)