From 2a885c30cc7b6ea4d88e82001d8526b72620798e Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Mon, 29 Jul 2024 16:29:13 +0900 Subject: [PATCH] rpm: fix usage of substr argument As we need to handle *whole string" as input, using $0 is correct. (though as it doesn't contains separator, $0/$1 seems same for awk) Signed-off-by: Kentaro Hayashi --- fluent-package/yum/binstubs-test.sh | 4 ++-- fluent-package/yum/confluent-test.sh | 4 ++-- fluent-package/yum/install-test.sh | 4 ++-- fluent-package/yum/serverspec-test.sh | 4 ++-- fluent-package/yum/systemd-test/commonvar.sh | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fluent-package/yum/binstubs-test.sh b/fluent-package/yum/binstubs-test.sh index 00ce32bc4..d039d2067 100755 --- a/fluent-package/yum/binstubs-test.sh +++ b/fluent-package/yum/binstubs-test.sh @@ -14,8 +14,8 @@ if [ "$CI" = "true" ]; then echo "::group::Setup binstubs test" fi -distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2) -version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4) +distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f2) +version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f4) ENABLE_UPGRADE_TEST=1 case ${distribution} in diff --git a/fluent-package/yum/confluent-test.sh b/fluent-package/yum/confluent-test.sh index 690312d3d..8854b769c 100755 --- a/fluent-package/yum/confluent-test.sh +++ b/fluent-package/yum/confluent-test.sh @@ -13,8 +13,8 @@ fi # This means that column glitch exists. # So, we should remove before "o" character. -distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2) -version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4) +distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f2) +version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f4) case ${distribution} in amazon) diff --git a/fluent-package/yum/install-test.sh b/fluent-package/yum/install-test.sh index 0fed1ae5e..921f68386 100755 --- a/fluent-package/yum/install-test.sh +++ b/fluent-package/yum/install-test.sh @@ -11,8 +11,8 @@ set -exu # This means that column glitch exists. # So, we should remove before "o" character. -distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2) -version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4) +distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f2) +version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f4) ENABLE_UPGRADE_TEST=1 case ${distribution} in diff --git a/fluent-package/yum/serverspec-test.sh b/fluent-package/yum/serverspec-test.sh index e5141022f..b40463273 100755 --- a/fluent-package/yum/serverspec-test.sh +++ b/fluent-package/yum/serverspec-test.sh @@ -15,8 +15,8 @@ if [ "$CI" = "true" ]; then echo "::group::Setup serverspec test" fi -distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2) -version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4) +distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f2) +version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($0, "o"))}' | cut -d: -f4) case ${distribution} in amazon) diff --git a/fluent-package/yum/systemd-test/commonvar.sh b/fluent-package/yum/systemd-test/commonvar.sh index e056a2e47..9a847fd8a 100755 --- a/fluent-package/yum/systemd-test/commonvar.sh +++ b/fluent-package/yum/systemd-test/commonvar.sh @@ -1,7 +1,7 @@ #!/bin/bash -distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2) -version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4) +distribution=$(cat /etc/system-release-cpe | awk '{print substr($1, index($1, "o"))}' | cut -d: -f2) +version=$(cat /etc/system-release-cpe | awk '{print substr($1, index($1, "o"))}' | cut -d: -f4) td_agent_version=4.5.2 case $distribution in