From: Matthew Watkins Date: Thu, 29 Feb 2024 12:54:46 +0000 (+0000) Subject: Fix: Address various shellcheck linting errors in scripts X-Git-Tag: v0.90.2^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=8901fe0bee2fecb6b32accffd9f952d46da59a38;p=releng%2Fglobal-jjb.git Fix: Address various shellcheck linting errors in scripts Issue: RELENG-5183 Change-Id: I068c27b215fd487985d6204af05fe6619c9d8f15 Signed-off-by: Matthew Watkins --- diff --git a/releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml b/releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml new file mode 100644 index 00000000..b237658c --- /dev/null +++ b/releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Address several linting errors in scripts, mostly unquoted variables diff --git a/shell/openstack-cleanup-orphaned-objects.sh b/shell/openstack-cleanup-orphaned-objects.sh index 59e1edff..689eab27 100755 --- a/shell/openstack-cleanup-orphaned-objects.sh +++ b/shell/openstack-cleanup-orphaned-objects.sh @@ -83,11 +83,11 @@ trap _rmtemp EXIT # Output the initial list of object UUIDs to a temporary file if [[ -n ${filters} ]]; then # If a filter/match condition is requested/set - openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \ + openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID "$attributes" \ | { $filters || true; } | { awk '{print $1}' || true; } > "$tmpfile" else # Otherwise don't pipe through an additional command - openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \ + openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID "$attributes" \ | { awk '{print $1}' || true; } > "$tmpfile" fi diff --git a/shell/release-job.sh b/shell/release-job.sh index 57e40387..e01d3a93 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -97,7 +97,7 @@ set_variables_common(){ TAG_RELEASE="${TAG_RELEASE:-None}" if [[ $TAG_RELEASE == "None" ]]; then - if grep -q "tag_release" $release_file ; then + if grep -q "tag_release" "$release_file"; then TAG_RELEASE=$(yq -r .tag_release "$release_file") else TAG_RELEASE=true @@ -183,7 +183,7 @@ set_variables_packagecloud(){ VERSION=$(yq -r ".version" "$release_file") fi if [[ -z ${GIT_TAG:-} ]]; then - if grep -q "git_tag" $release_file ; then + if grep -q "git_tag" "$release_file"; then GIT_TAG=$(yq -r ".git_tag" "$release_file") else GIT_TAG="$VERSION" @@ -385,8 +385,8 @@ artifact_release_file(){ mkdir artifacts ORG=$(echo "$NEXUS_URL" | awk -F'.' '{print $2}') - for namequoted in $(yq '.artifacts[].name' $release_file); do - pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" $release_file) + for namequoted in $(yq '.artifacts[].name' "$release_file"); do + pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" "$release_file") #Remove extra yaml quotes name="${namequoted#\"}" @@ -420,8 +420,8 @@ container_release_file(){ local lfn_umbrella lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')" - for namequoted in $(yq '.containers[].name' $release_file); do - versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" $release_file) + for namequoted in $(yq '.containers[].name' "$release_file"); do + versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" "$release_file") #Remove extra yaml quotes name="${namequoted#\"}" @@ -657,7 +657,7 @@ case $DISTRIBUTION_TYPE in fi set_variables_packagecloud verify_packagecloud_match_release - for name in $(yq -r '.packages[].name' $release_file); do + for name in $(yq -r '.packages[].name' "$release_file"); do package=$name packagecloud_verify "$package" "$packagecloud_account" if [[ "$JOB_NAME" =~ "merge" ]] && ! $DRY_RUN; then