From 74c2152a908804374ebaddb948928f759b24ac48 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 15:55:05 +0000 Subject: [PATCH 1/4] Initial plan From 4677a943fa9c95d29fb46d6c65ade791ca018305 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:01:16 +0000 Subject: [PATCH 2/4] Fix all major install.sh issues - syntax, shellcheck, checksum verification Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com> --- install.sh | 114 +++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 64 deletions(-) diff --git a/install.sh b/install.sh index e0327a0..71352ae 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ # Copyright Tim Voronov 2020 version=$(curl -sI https://github.com/go-waitfor/cli/releases/latest | grep Location | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r') -if [ ! $version ]; then +if [ ! "$version" ]; then echo "Failed while attempting to install waitfor. Please manually install:" echo "" echo "1. Open your web browser and go to https://github.com/go-waitfor/cli/releases" @@ -13,9 +13,7 @@ if [ ! $version ]; then fi hasCli() { - has=$(which waitfor) - - if [ "$?" = "0" ]; then + if which waitfor >/dev/null 2>&1; then echo echo "You already have waitfor!" export n=3 @@ -24,16 +22,12 @@ hasCli() { sleep $n fi - hasCurl=$(which curl) - - if [ "$?" = "1" ]; then + if ! which curl >/dev/null 2>&1; then echo "You need curl to use this script." exit 1 fi - hasTar=$(which tar) - - if [ "$?" = "1" ]; then + if ! which tar >/dev/null 2>&1; then echo "You need tar to use this script." exit 1 fi @@ -42,15 +36,12 @@ hasCli() { checkHash(){ sha_cmd="sha256sum" - if [ ! -x "$(command -v $sha_cmd)" ]; then + if [ ! -x "$(command -v "$sha_cmd")" ]; then sha_cmd="shasum -a 256" fi - if [ -x "$(command -v $sha_cmd)" ]; then - - (cd $targetDir && curl -sSL $baseUrl/waitfor_checksums.txt | $sha_cmd -c >/dev/null) - if [ "$?" != "0" ]; then - # rm $targetFile + if [ -x "$(command -v "$sha_cmd")" ]; then + if ! (cd "$targetDir" && curl -sSL "$baseUrl"/checksums.txt | "$sha_cmd" -c >/dev/null); then echo "Binary checksum didn't match. Exiting" exit 1 fi @@ -71,23 +62,20 @@ getPackage() { ;; esac - uname=$(uname -m) + uname_arch=$(uname -m) arch="" - case $uname in + case $uname_arch in "x86_64") - arch="_x86_64" - ;; - esac - case $uname in - "aarch64") - arch="_arm64" - ;; - esac - - if [ "$arch" == "" ]; then - echo "${$arch} is not supported. Exiting" + arch="_amd64" + ;; + "aarch64"|"arm64") + arch="_arm64" + ;; + *) + echo "Architecture $uname_arch is not supported. Exiting" exit 1 - fi + ;; + esac suffix=$platform$arch targetDir="/tmp/waitfor$suffix" @@ -96,56 +84,54 @@ getPackage() { targetDir="$(pwd)/waitfor$suffix" fi - if [ ! -d $targetDir ]; then - mkdir $targetDir + if [ ! -d "$targetDir" ]; then + mkdir "$targetDir" fi targetFile="$targetDir/waitfor" - if [ -e $targetFile ]; then - rm $targetFile + if [ -e "$targetFile" ]; then + rm "$targetFile" fi baseUrl=https://github.com/go-waitfor/cli/releases/download/$version url=$baseUrl/waitfor$suffix.tar.gz echo "Downloading package $url as $targetFile" - curl -sSL $url | tar xz -C $targetDir - - if [ "$?" = "0" ]; then + if ! curl -sSL "$url" | tar xz -C "$targetDir"; then + echo "Failed to download or extract package" + exit 1 + fi - # checkHash + checkHash - chmod +x $targetFile + chmod +x "$targetFile" echo "Download complete." - if [ "$userid" != "0" ]; then - echo - echo "=========================================================" - echo "== As the script was run as a non-root user the ==" - echo "== following commands may need to be run manually ==" - echo "=========================================================" - echo - echo " sudo cp $targetFile /usr/local/bin/waitfor" - echo " rm -rf $targetDir" - echo - else - echo - echo "Running as root - Attempting to move $targetFile to /usr/local/bin" - - mv $targetFile /usr/local/bin/waitfor - - if [ "$?" = "0" ]; then - echo "New version of waitfor installed to /usr/local/bin" - fi - - if [ -d $targetDir ]; then - rm -rf $targetDir - fi - - waitfor version + if [ "$userid" != "0" ]; then + echo + echo "=========================================================" + echo "== As the script was run as a non-root user the ==" + echo "== following commands may need to be run manually ==" + echo "=========================================================" + echo + echo " sudo cp \"$targetFile\" /usr/local/bin/waitfor" + echo " rm -rf \"$targetDir\"" + echo + else + echo + echo "Running as root - Attempting to move \"$targetFile\" to /usr/local/bin" + + if mv "$targetFile" /usr/local/bin/waitfor; then + echo "New version of waitfor installed to /usr/local/bin" fi + + if [ -d "$targetDir" ]; then + rm -rf "$targetDir" + fi + + waitfor version fi } From 93909f83a0d170613387770218c6288a142b0a66 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:02:05 +0000 Subject: [PATCH 3/4] Add unsupported platform detection and comprehensive validation Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com> --- install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 71352ae..b3c718b 100644 --- a/install.sh +++ b/install.sh @@ -55,11 +55,15 @@ getPackage() { platform="" case $uname in "Darwin") - platform="_darwin" - ;; + platform="_darwin" + ;; "Linux") - platform="_linux" - ;; + platform="_linux" + ;; + *) + echo "Platform $uname is not supported. Exiting" + exit 1 + ;; esac uname_arch=$(uname -m) From f5902cc16ebb58012dcd8ae12512c11a81af4f7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:25:05 +0000 Subject: [PATCH 4/4] Implement fallback to 'latest' instead of failing when version detection fails Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com> --- install.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index b3c718b..aece270 100644 --- a/install.sh +++ b/install.sh @@ -3,13 +3,8 @@ # Copyright Tim Voronov 2020 version=$(curl -sI https://github.com/go-waitfor/cli/releases/latest | grep Location | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r') if [ ! "$version" ]; then - echo "Failed while attempting to install waitfor. Please manually install:" - echo "" - echo "1. Open your web browser and go to https://github.com/go-waitfor/cli/releases" - echo "2. Download the latest release for your platform." - echo "3. chmod +x ./waitfor" - echo "4. mv ./waitfor /usr/local/bin" - exit 1 + echo "Unable to detect latest version, falling back to 'latest'" + version="latest" fi hasCli() { @@ -98,7 +93,11 @@ getPackage() { rm "$targetFile" fi - baseUrl=https://github.com/go-waitfor/cli/releases/download/$version + if [ "$version" = "latest" ]; then + baseUrl=https://github.com/go-waitfor/cli/releases/latest/download + else + baseUrl=https://github.com/go-waitfor/cli/releases/download/$version + fi url=$baseUrl/waitfor$suffix.tar.gz echo "Downloading package $url as $targetFile"