[OS-BUILD PATCHv2 6/20] [redhat] download_cross.sh: Fix syntax flagged by shellcheck

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

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

SC2068: Double quote array expansions to avoid re-splitting elements.
SC2086: Double quote to prevent globbing and word splitting.
SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>
---
 redhat/scripts/download_cross.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/redhat/scripts/download_cross.sh b/redhat/scripts/download_cross.sh
index 2e2f719a43f8..c5583498d111 100755
--- a/redhat/scripts/download_cross.sh
+++ b/redhat/scripts/download_cross.sh
@@ -13,7 +13,7 @@
 # if there's already a cross-compiler specified, assume we're done
 if [ "$ARCH" ]; then
 	if [ "$CROSS_COMPILE" ]; then
-		crossbin=$(whereis -b ${CROSS_COMPILE}gcc | cut -d: -f2 | cut -d' ' -f2)
+		crossbin=$(whereis -b "$CROSS_COMPILE"gcc | cut -d: -f2 | cut -d' ' -f2)
 		if [ "$crossbin" ]; then
 			echo "Using $crossbin as the cross-compiler."
 			exit 0
@@ -27,8 +27,7 @@ fi
 # if we're not root, all we can do now is see what's installed
 if [ "$(whoami)" != "root" ]; then
 	echo "Checking for RHEL7 cross compile packages.  If this fails, run \"make dist-cross-download\" as root."
-	rpm -q $@
-	if [ $? == 0 ]; then
+	if rpm -q "$@" >& /dev/null; then
 		echo "Compilers found."
 		exit 0
 	else
@@ -38,11 +37,11 @@ if [ "$(whoami)" != "root" ]; then
 fi
 
 # if everything is installed then exit successfully
-rpm -q $@ && exit 0
+rpm -q "$@" && exit 0
 
 # install epel-release if necessary
-rpm -q epel-release >& /dev/null
-if [ $? -ne 0 ]; then
+
+if ! rpm -q epel-release >& /dev/null; then
 	wget -nd -r -l1 --no-parent -A "epel-release*.rpm" http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
 	rpm -ivh epel-release*.rpm
 	# clean up
@@ -50,6 +49,6 @@ if [ $? -ne 0 ]; then
 fi
 
 # install list of rpms for cross compile
-yum -y install $@
+yum -y install "$@"
 
 exit 0
-- 
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