@@ -75,14 +75,14 @@ echo "Downloading from: $DOWNLOAD_URL"
7575
7676# Download and extract with error handling
7777TMP_DIR=" $( mktemp -d) "
78+ trap ' rm -rf -- "$TMP_DIR"' EXIT
7879TMP_TARBALL=" $TMP_DIR /copilot-${PLATFORM} -${ARCH} .tar.gz"
7980if command -v curl > /dev/null 2>&1 ; then
8081 curl -fsSL " ${CURL_AUTH[@]} " " $DOWNLOAD_URL " -o " $TMP_TARBALL "
8182elif command -v wget > /dev/null 2>&1 ; then
8283 wget -qO " $TMP_TARBALL " " ${WGET_AUTH[@]} " " $DOWNLOAD_URL "
8384else
8485 echo " Error: Neither curl nor wget found. Please install one of them."
85- rm -rf " $TMP_DIR "
8686 exit 1
8787fi
8888
@@ -101,15 +101,13 @@ if [ "$CHECKSUMS_AVAILABLE" = true ]; then
101101 echo " ✓ Checksum validated"
102102 else
103103 echo " Error: Checksum validation failed." >&2
104- rm -rf " $TMP_DIR "
105104 exit 1
106105 fi
107106 elif command -v shasum > /dev/null 2>&1 ; then
108107 if (cd " $TMP_DIR " && shasum -a 256 -c --ignore-missing SHA256SUMS.txt > /dev/null 2>&1 ); then
109108 echo " ✓ Checksum validated"
110109 else
111110 echo " Error: Checksum validation failed." >&2
112- rm -rf " $TMP_DIR "
113111 exit 1
114112 fi
115113 else
120118# Check that the file is a valid tarball
121119if ! tar -tzf " $TMP_TARBALL " > /dev/null 2>&1 ; then
122120 echo " Error: Downloaded file is not a valid tarball or is corrupted." >&2
123- rm -rf " $TMP_DIR "
124121 exit 1
125122fi
126123
144141tar -xz -C " $INSTALL_DIR " -f " $TMP_TARBALL "
145142chmod +x " $INSTALL_DIR /copilot"
146143echo " ✓ GitHub Copilot CLI installed to $INSTALL_DIR /copilot"
147- rm -rf " $TMP_DIR "
148144
149145# Check if installed binary is accessible
150146if ! command -v copilot > /dev/null 2>&1 ; then
0 commit comments