From 7e11489daf48b37b5d0686ff34226a19dfd81682 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= <ldoktor@redhat.com>
Date: Wed, 19 Mar 2025 10:46:56 +0100
Subject: [PATCH] ci: shellcheck - collection of fixes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

manual fixes of various issues.

Related to: #10951

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
---
 ci/gh-util.sh            | 7 ++++---
 ci/install_libseccomp.sh | 5 ++---
 ci/install_yq.sh         | 3 +--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/ci/gh-util.sh b/ci/gh-util.sh
index 449b078682..250eb646c2 100755
--- a/ci/gh-util.sh
+++ b/ci/gh-util.sh
@@ -95,7 +95,7 @@ list_issues_for_pr()
     echo "# Fields: issue_number"
 
     local issue
-    echo "${issues}"|while read issue
+    echo "${issues}" | while read -r issue
     do
         printf "%s\n" "${issue}"
     done
@@ -112,7 +112,7 @@ list_labels_for_issue()
 
     [[ -z "${labels}" ]] && die "cannot determine labels for issue ${issue}"
 
-    printf "${labels}"
+    echo "${labels}"
 }
 
 setup()
@@ -134,10 +134,11 @@ handle_args()
         case "${opt}" in
             h) usage && exit 0 ;;
             r) repo="${OPTARG}" ;;
+			*) echo "use '-h' to get list of supprted aruments" && exit 1 ;;
         esac
     done
 
-    shift $((${OPTIND} - 1))
+    shift $((OPTIND - 1))
 
     local repo="${repo:-kata-containers/kata-containers}"
     local cmd="${1:-}"
diff --git a/ci/install_libseccomp.sh b/ci/install_libseccomp.sh
index 395dcaf8a0..a18ce72686 100755
--- a/ci/install_libseccomp.sh
+++ b/ci/install_libseccomp.sh
@@ -8,7 +8,6 @@
 set -o errexit
 
 script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-script_name="$(basename "${BASH_SOURCE[0]}")"
 
 source "${script_dir}/../tests/common.bash"
 
@@ -47,7 +46,7 @@ gperf_tarball_url="${gperf_url}/${gperf_tarball}"
 
 # We need to build the libseccomp library from sources to create a static library for the musl libc.
 # However, ppc64le and s390x have no musl targets in Rust. Hence, we do not set cflags for the musl libc.
-if ([[ "${arch}" != "ppc64le" ]] && [[ "${arch}" != "s390x" ]]); then
+if [[ "${arch}" != "ppc64le" ]] && [[ "${arch}" != "s390x" ]]; then
 	# Set FORTIFY_SOURCE=1 because the musl-libc does not have some functions about FORTIFY_SOURCE=2
 	cflags="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2"
 fi
@@ -71,7 +70,7 @@ build_and_install_gperf() {
 	tar -xf "${gperf_tarball}"
 	pushd "gperf-${gperf_version}"
 	# Unset $CC for configure, we will always use native for gperf
-	CC= ./configure --prefix="${gperf_install_dir}"
+	CC="" ./configure --prefix="${gperf_install_dir}"
 	make
 	make install
 	export PATH=${PATH}:"${gperf_install_dir}"/bin
diff --git a/ci/install_yq.sh b/ci/install_yq.sh
index bd0dbb3b2c..ffc91d3dfa 100755
--- a/ci/install_yq.sh
+++ b/ci/install_yq.sh
@@ -107,8 +107,7 @@ function install_yq() {
 
 	## NOTE: ${var,,} => gives lowercase value of var
 	local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
-	${precmd} curl -o "${yq_path}" -LSsf "${yq_url}"
-	[[ $? -ne 0 ]] && die "Download ${yq_url} failed"
+	${precmd} curl -o "${yq_path}" -LSsf "${yq_url}" || die "Download ${yq_url} failed"
 	${precmd} chmod +x "${yq_path}"
 
 	if ! command -v "${yq_path}" >/dev/null; then