From d56cc819b69e198d4ab00fdeb1c5bcf5f9bff35e Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 1 Nov 2025 21:18:24 -0700 Subject: [PATCH 1/2] Configure grep commands in installation script to use POSIX extended syntax A script is provided to facilitate installation of Arduino Lint. The grep utility is used for several purposes in the script. grep supports multiple flavors of regular expression syntax: * "basic" (BRE) * "extended" (ERE) * "perl" (PCRE) The default "BRE" syntax is inconsistent with the syntax used in all other common regular expression applications: > In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the > backslashed versions \?, \+, \{, \|, \(, and \). The "PCRE" syntax that would otherwise be preferred is not available when using grep on BSD/macOS machines. So grep should be configured to use the "ERE" in scripts that are intended to be cross-platform (as is the case with this script). --- etc/install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/install.sh b/etc/install.sh index a450a9fd5..fd45e71bc 100755 --- a/etc/install.sh +++ b/etc/install.sh @@ -87,9 +87,9 @@ checkLatestVersion() { CHECKLATESTVERSION_REGEX="[0-9][A-Za-z0-9\.-]*" CHECKLATESTVERSION_LATEST_URL="https://github.com/${PROJECT_OWNER}/${PROJECT_NAME}/releases/latest" if [ "$DOWNLOAD_TOOL" = "curl" ]; then - CHECKLATESTVERSION_TAG=$(curl -SsL $CHECKLATESTVERSION_LATEST_URL | grep -o "Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep -o "$CHECKLATESTVERSION_REGEX") + CHECKLATESTVERSION_TAG=$(curl -SsL $CHECKLATESTVERSION_LATEST_URL | grep --extended-regexp -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep --extended-regexp -o "$CHECKLATESTVERSION_REGEX") elif [ "$DOWNLOAD_TOOL" = "wget" ]; then - CHECKLATESTVERSION_TAG=$(wget -q -O - $CHECKLATESTVERSION_LATEST_URL | grep -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep -o "$CHECKLATESTVERSION_REGEX") + CHECKLATESTVERSION_TAG=$(wget -q -O - $CHECKLATESTVERSION_LATEST_URL | grep --extended-regexp -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep --extended-regexp -o "$CHECKLATESTVERSION_REGEX") fi if [ "$CHECKLATESTVERSION_TAG" = "" ]; then echo "Cannot determine latest tag." @@ -168,9 +168,9 @@ downloadFile() { fi # || true forces this command to not catch error if grep does not find anything - DOWNLOAD_URL=$(echo "$BODY" | grep 'browser_' | cut -d\" -f4 | grep "$APPLICATION_DIST") || true + DOWNLOAD_URL=$(echo "$BODY" | grep --extended-regexp 'browser_' | cut -d\" -f4 | grep --extended-regexp "$APPLICATION_DIST") || true if [ -z "$DOWNLOAD_URL" ]; then - DOWNLOAD_URL=$(echo "$BODY" | grep 'browser_' | cut -d\" -f4 | grep "$FALLBACK_APPLICATION_DIST") || true + DOWNLOAD_URL=$(echo "$BODY" | grep --extended-regexp 'browser_' | cut -d\" -f4 | grep --extended-regexp "$FALLBACK_APPLICATION_DIST") || true fi if [ -z "$DOWNLOAD_URL" ]; then From 36004ef64acace98fc1d9c9017328f30eaaa8f7f Mon Sep 17 00:00:00 2001 From: per1234 <accounts@perglass.com> Date: Sat, 1 Nov 2025 21:25:31 -0700 Subject: [PATCH 2/2] Improve version number regex in installation script The installation script scrapes the GitHub releases page for the version number of the latest release. A regular expression is used to extract the version number from the title. Previously, the regular expression would return a corrupted version number if the name of the repository owner or repository contained numbers. For example, if used in a repository owned by GitHub user `per1234`, where the latest release version was 1.2.3, it would return the following version number: ``` 1.2.3 1234 ``` --- etc/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/install.sh b/etc/install.sh index fd45e71bc..9f104a6be 100755 --- a/etc/install.sh +++ b/etc/install.sh @@ -84,7 +84,7 @@ initDownloadTool() { checkLatestVersion() { # Use the GitHub releases webpage to find the latest version for this project # so we don't get rate-limited. - CHECKLATESTVERSION_REGEX="[0-9][A-Za-z0-9\.-]*" + CHECKLATESTVERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\.-]+)?" CHECKLATESTVERSION_LATEST_URL="https://github.com/${PROJECT_OWNER}/${PROJECT_NAME}/releases/latest" if [ "$DOWNLOAD_TOOL" = "curl" ]; then CHECKLATESTVERSION_TAG=$(curl -SsL $CHECKLATESTVERSION_LATEST_URL | grep --extended-regexp -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep --extended-regexp -o "$CHECKLATESTVERSION_REGEX")