From 62d94da73dcf0fa910eea7f6f59a16e85e918810 Mon Sep 17 00:00:00 2001 From: Philipp Hahn <hahn@univention.de> Date: Tue, 23 Apr 2024 15:17:12 +0200 Subject: [PATCH] refactor: drop use-less use of cat --- .gitlab-ci.yml | 2 +- .gitlab/scripts/check-semantic-version.sh | 2 +- tests/unit.gitlab-ci.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 424603e..68134fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -265,7 +265,7 @@ create-release: - export AVAILABLE_OPENTOFU_VERSIONS - 'AVAILABLE_IMAGES=$(cat image*.md | sort -r | tee images.md | sed -E "s/(\(digest: .*\))/\n - \1/")' - export AVAILABLE_IMAGES - - cat .gitlab/release-notes.md.template | envsubst > release-notes.md + - envsubst < .gitlab/release-notes.md.template > release-notes.md artifacts: paths: - images.md diff --git a/.gitlab/scripts/check-semantic-version.sh b/.gitlab/scripts/check-semantic-version.sh index 7a7a5b7..376af8f 100755 --- a/.gitlab/scripts/check-semantic-version.sh +++ b/.gitlab/scripts/check-semantic-version.sh @@ -3,7 +3,7 @@ # Regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SEMANTIC_VERSION_REGEX='^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' -match=$(cat - | perl -ne "print if /$SEMANTIC_VERSION_REGEX/") +match=$(perl -ne "print if /$SEMANTIC_VERSION_REGEX/") if [ -z "$match" ]; then echo "The given version doesn't match the semantic versioning format." diff --git a/tests/unit.gitlab-ci.yml b/tests/unit.gitlab-ci.yml index 64103f7..e307e3d 100644 --- a/tests/unit.gitlab-ci.yml +++ b/tests/unit.gitlab-ci.yml @@ -132,7 +132,7 @@ gitlab-tofu-init-without-reconfigure: - gitlab-tofu init -no-color >/tmp/output.txt 2>&1 || FAILED=true - cat /tmp/output.txt - test $FAILED = true - - 'cat /tmp/output.txt | grep "Error: Backend configuration changed"' + - 'grep "Error: Backend configuration changed" /tmp/output.txt' gitlab-tofu-init-with-reconfigure: extends: @@ -306,7 +306,7 @@ gitlab-tofu-without-implicit-init: - gitlab-tofu $CMD -no-color >/tmp/output.txt 2>&1 || FAILED=true - cat /tmp/output.txt - test $FAILED = true - - 'cat /tmp/output.txt | grep "$ERROR"' + - 'grep "$ERROR" /tmp/output.txt' parallel: matrix: - CMD: apply @@ -333,4 +333,4 @@ gitlab-tofu-no-wrapper: - gitlab-tofu -- apply -no-color >/tmp/output.txt 2>&1 || FAILED=true - cat /tmp/output.txt - test $FAILED = true - - 'cat /tmp/output.txt | grep "Error: Backend initialization required, please run \"tofu init\""' + - 'grep "Error: Backend initialization required, please run \"tofu init\"" /tmp/output.txt' -- GitLab