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

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

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

Disable by changing to #!/bin/bash:

SC2039: In POSIX sh, echo flags are undefined.
SC2039: In POSIX sh, >& is undefined.

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>
---
 redhat/scripts/generate-cross-report.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/redhat/scripts/generate-cross-report.sh b/redhat/scripts/generate-cross-report.sh
index 1d4255fdc1cf..ca47543c71cf 100755
--- a/redhat/scripts/generate-cross-report.sh
+++ b/redhat/scripts/generate-cross-report.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # This script is called by the cross compile targets in redhat/Makefile.cross.
 # The script outputs information for use by the maintainers to confirm that
@@ -21,44 +21,43 @@ cat /etc/redhat-release
 
 # System name
 echo -n "System name: "
-HOSTNAME=`hostname`
+HOSTNAME=$(hostname)
 
 if [ -e ~/.rpmmacros ]; then
-	cat ~/.rpmmacros | grep smp_mflags >& /dev/null
-	if [ $? -eq 0 ]; then
-		smpflags=`cat ~/.rpmmacros | awk -F " " ' { print $2 } '`
+	if grep -q smp_mflags ~/.rpmmacros; then
+		smpflags=$(awk -F " " ' { print $2 } ' ~/.rpmmacros )
 		echo "$HOSTNAME with $smpflags"
 	fi
 else
-	echo $HOSTNAME
+	echo "$HOSTNAME"
 fi
 
 # Last known tag
-lasttag=`git describe --abbrev=0 --tags`
+lasttag=$(git describe --abbrev=0 --tags)
 echo "Built on: $lasttag"
 
 # Arches built?
 # would have to be passed in on command line as string?
 echo -n "Arch built: "
-echo $1
+echo "$1"
 
 # Was CROSS_COMPILE set to use non-standard compilers?
 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)
 	echo "==============================================================================="
 	echo "For patch submissions, use only supported cross-compilers for testing."
 	echo "CROSS_COMPILE set to: $CROSS_COMPILE"
 else
-	crossbin=$(whereis -b ${1}-linux-gnu-gcc | cut -d: -f2 | cut -d' ' -f2)
+	crossbin=$(whereis -b "$1"-linux-gnu-gcc | cut -d: -f2 | cut -d' ' -f2)
 fi
-test -x $crossbin && echo "Cross-compiler used: $crossbin"
+test -x "$crossbin" && echo "Cross-compiler used: $crossbin"
 
 
 echo "==============================================================================="
 echo "For patch submissions this can optionally be included to show the changes"
 echo "that were compiled into the tree."
 echo "diffstat output (relative to $lasttag)"
-git diff $lasttag | diffstat
+git diff "$lasttag" | diffstat
 
 echo "==============================================================================="
 echo "==============================================================================="
-- 
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