From 4b3bed3c9a6f4bcff75bb6c9391e727b534dc773 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 30 Jun 2020 11:46:35 -0700 Subject: [PATCH] [skip ci] Fix installation script's latest tag determination code GitHub changed the HTML of the release page, which resulted in grep finding multiple instances of the pattern, causing the installation script to fail when no version parameter was provided: $ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh Installing in /home/per/temporary/bin ARCH=64bit OS=Linux Using curl as download tool TAG=0.11.0 0.11.0 0.11.0 CLI_DIST=arduino-cli_0.11.0 0.11.0 0.11.0_Linux_64bit.tar.gz Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_0.11.0 0.11.0 0.11.0_Linux_64bit.tar.gz Failed to install arduino-cli The chosen fix was to expand the grep pattern to something that should only ever occur once on an HTML page. --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index cad8885c6bd..7d3ed301f2b 100755 --- a/install.sh +++ b/install.sh @@ -84,9 +84,9 @@ checkLatestVersion() { local regex="[0-9][A-Za-z0-9\.-]*" local latest_url="https://github.com/arduino/arduino-cli/releases/latest" if [ "$DOWNLOAD_TOOL" = "curl" ]; then - tag=$(curl -SsL $latest_url | grep -o "Release $regex · arduino/arduino-cli" | grep -o "$regex") + tag=$(curl -SsL $latest_url | grep -o "Release $regex · arduino/arduino-cli" | grep -o "$regex") elif [ "$DOWNLOAD_TOOL" = "wget" ]; then - tag=$(wget -q -O - $latest_url | grep -o "Release $regex · arduino/arduino-cli" | grep -o "$regex") + tag=$(wget -q -O - $latest_url | grep -o "<title>Release $regex · arduino/arduino-cli" | grep -o "$regex") fi if [ "x$tag" = "x" ]; then echo "Cannot determine latest tag."