From dd646d7b7feddf1e7660f8cf080a2c924ef657db Mon Sep 17 00:00:00 2001 From: Phred Lane Date: Fri, 27 Sep 2024 02:59:31 -0500 Subject: [PATCH] chore: simplified awk usage for version extraction (#5893) --- docs/add-new-linter.md | 5 ++++- scripts/install-checkstyle.sh | 2 +- scripts/install-google-java-format.sh | 2 +- scripts/install-ktlint.sh | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/add-new-linter.md b/docs/add-new-linter.md index 451c64e1..fc4c0bae 100644 --- a/docs/add-new-linter.md +++ b/docs/add-new-linter.md @@ -75,7 +75,10 @@ new tool needs in the `PATH`, and the expected version command: `build.gradle`. Example: ```sh - GOOGLE_JAVA_FORMAT_VERSION="$(grep <"google-java-format/build.gradle" "google-java-format" | awk -F ':' '{print $3}' | tr -d "'")" + GOOGLE_JAVA_FORMAT_VERSION="$( + set -euo pipefail + awk -F "[:']" '/google-java-format/ {print $4}' "google-java-format/build.gradle" + )" ``` 6. Add the new to DependaBot configuration: diff --git a/scripts/install-checkstyle.sh b/scripts/install-checkstyle.sh index 66a38bae..148b715d 100755 --- a/scripts/install-checkstyle.sh +++ b/scripts/install-checkstyle.sh @@ -4,7 +4,7 @@ set -euo pipefail CHECKSTYLE_VERSION="$( set -euo pipefail - grep <"checkstyle/build.gradle" "checkstyle" | awk -F ':' '{print $3}' | tr -d "'" + awk -F "[:']" '/checkstyle/ {print $4}' "checkstyle/build.gradle" )" echo "Installing Checkstyle: ${CHECKSTYLE_VERSION}" diff --git a/scripts/install-google-java-format.sh b/scripts/install-google-java-format.sh index 32532dbc..a788bda2 100755 --- a/scripts/install-google-java-format.sh +++ b/scripts/install-google-java-format.sh @@ -4,7 +4,7 @@ set -euo pipefail GOOGLE_JAVA_FORMAT_VERSION="$( set -euo pipefail - grep <"google-java-format/build.gradle" "google-java-format" | awk -F ':' '{print $3}' | tr -d "'" + awk -F "[:']" '/google-java-format/ {print $4}' "google-java-format/build.gradle" )" echo "Installing Google Java Format: ${GOOGLE_JAVA_FORMAT_VERSION}" diff --git a/scripts/install-ktlint.sh b/scripts/install-ktlint.sh index 41f3b0bf..fc3cf8e8 100755 --- a/scripts/install-ktlint.sh +++ b/scripts/install-ktlint.sh @@ -4,7 +4,7 @@ set -euo pipefail KTLINT_VERSION="$( set -euo pipefail - grep <"ktlint/build.gradle" "ktlint" | awk -F ':' '{print $3}' | tr -d "'" + awk -F "[:']" '/ktlint/ {print $4}' "ktlint/build.gradle" )" echo "Installing Ktlint: ${KTLINT_VERSION}"