Skip to content

Commit d56cc81

Browse files
committed
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).
1 parent f873da4 commit d56cc81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

etc/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ checkLatestVersion() {
8787
CHECKLATESTVERSION_REGEX="[0-9][A-Za-z0-9\.-]*"
8888
CHECKLATESTVERSION_LATEST_URL="https://github.com/${PROJECT_OWNER}/${PROJECT_NAME}/releases/latest"
8989
if [ "$DOWNLOAD_TOOL" = "curl" ]; then
90-
CHECKLATESTVERSION_TAG=$(curl -SsL $CHECKLATESTVERSION_LATEST_URL | grep -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep -o "$CHECKLATESTVERSION_REGEX")
90+
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")
9191
elif [ "$DOWNLOAD_TOOL" = "wget" ]; then
92-
CHECKLATESTVERSION_TAG=$(wget -q -O - $CHECKLATESTVERSION_LATEST_URL | grep -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep -o "$CHECKLATESTVERSION_REGEX")
92+
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")
9393
fi
9494
if [ "$CHECKLATESTVERSION_TAG" = "" ]; then
9595
echo "Cannot determine latest tag."
@@ -168,9 +168,9 @@ downloadFile() {
168168
fi
169169

170170
# || true forces this command to not catch error if grep does not find anything
171-
DOWNLOAD_URL=$(echo "$BODY" | grep 'browser_' | cut -d\" -f4 | grep "$APPLICATION_DIST") || true
171+
DOWNLOAD_URL=$(echo "$BODY" | grep --extended-regexp 'browser_' | cut -d\" -f4 | grep --extended-regexp "$APPLICATION_DIST") || true
172172
if [ -z "$DOWNLOAD_URL" ]; then
173-
DOWNLOAD_URL=$(echo "$BODY" | grep 'browser_' | cut -d\" -f4 | grep "$FALLBACK_APPLICATION_DIST") || true
173+
DOWNLOAD_URL=$(echo "$BODY" | grep --extended-regexp 'browser_' | cut -d\" -f4 | grep --extended-regexp "$FALLBACK_APPLICATION_DIST") || true
174174
fi
175175

176176
if [ -z "$DOWNLOAD_URL" ]; then

0 commit comments

Comments
 (0)