[OS-BUILD PATCH 8/20] [redhat] clone_tree.sh: Fix syntax flagged by shellcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2013: To read lines rather than words, pipe/redirect to a 'while read' loop.
SC2086: Double quote to prevent globbing and word splitting.
SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>
---
 redhat/scripts/clone_tree.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/redhat/scripts/clone_tree.sh b/redhat/scripts/clone_tree.sh
index 190594ea021b..810b0e5b123e 100755
--- a/redhat/scripts/clone_tree.sh
+++ b/redhat/scripts/clone_tree.sh
@@ -19,25 +19,25 @@ function die
 	exit 1;
 }
 
-date=`date +"%Y-%m-%d"`
-tmp="$(mktemp -d --tmpdir="$tmp_dir" RHEL$rhel_major.$date.XXXXXXXX)";
-cd $tmp || die "Unable to create temporary directory";
+date=$(date +"%Y-%m-%d")
+tmp="$(mktemp -d --tmpdir="$tmp_dir" RHEL"$rhel_major"."$date".XXXXXXXX)";
+cd "$tmp" || die "Unable to create temporary directory";
 
-if [ -n "$repo" -a -n "$local" ]; then
-	git clone --reference $local $repo $package_name >/dev/null || die "Unable to clone using local cache";
+if [ -n "$repo" ] && [ -n "$local" ]; then
+	git clone --reference "$local" "$repo" "$package_name" >/dev/null || die "Unable to clone using local cache";
 	# if there're tarballs present that are listed in the "sources" file,
 	# copy them or it'll be downloaded again
 	if [ -e "$local/sources" ]; then
-		for i in $(cat "$local/sources"); do
+		while IFS= read -r i; do
 			if [ -f "$local/$i" ]; then
 				cp "$local/$i" "$tmp/kernel/";
 			fi
-		done
+		done < "$local"/sources
 	fi
 else
 	echo "No local repo, cloning using $rhpkg_bin" >&2;
-	$rhpkg_bin clone $package_name >/dev/null || die "Unable to clone using $rhpkg_bin";
+	$rhpkg_bin clone "$package_name" >/dev/null || die "Unable to clone using $rhpkg_bin";
 fi
 
-echo $tmp;
+echo "$tmp";
 
-- 
GitLab
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux