[OS-BUILD PATCHv2 10/20] [redhat] create-tarball.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 `...`.
SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
SC2086: Double quote to prevent globbing and word splitting.

BUT:
Disable shellcheck on last step:

On the last step, we DEPEND on word splitting for correct interpretation
of XZ_OPTIONS and XZ_THREADS, so remove quotes and, just before the
xz step:

  shellcheck disable=SC2086

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

diff --git a/redhat/scripts/create-tarball.sh b/redhat/scripts/create-tarball.sh
index c5a859f8efc3..fc85151acb89 100755
--- a/redhat/scripts/create-tarball.sh
+++ b/redhat/scripts/create-tarball.sh
@@ -4,9 +4,10 @@ GITID=$1
 TARBALL=$2
 DIR=$3
 
-XZ_THREADS=`rpm --eval %{_smp_mflags} | sed -e 's!^-j!--threads !'`
+# shellcheck disable=SC1083
+XZ_THREADS=$(rpm --eval %{_smp_mflags} | sed -e 's!^-j!--threads !')
 
-ARCH=`arch`
+ARCH=$(arch)
 XZ_OPTIONS=""
 
 if [ "$ARCH" != "x86_64" ]
@@ -14,17 +15,19 @@ then
         XZ_OPTIONS="-M 3G"
 fi
 
-if [ -f ${TARBALL} ]; then
-	TARID=`( xzcat -qq ${TARBALL} | git get-tar-commit-id ) 2>/dev/null`
-	GITID_NORMALIZE=`git log --max-count=1 --pretty=format:%H ${GITID}`
+if [ -f "$TARBALL" ]; then
+	TARID=$(xzcat -qq "$TARBALL" | git get-tar-commit-id 2>/dev/null)
+	GITID_NORMALIZE=$(git log --max-count=1 --pretty=format:%H "$GITID")
 	if [ "${GITID_NORMALIZE}" = "${TARID}" ]; then
-		echo "`basename ${TARBALL}` unchanged..."
+		echo "$(basename "$TARBALL") unchanged..."
 		exit 0
 	fi
-	rm -f ${TARBALL}
+	rm -f "$TARBALL"
 fi
 
-echo "Creating `basename ${TARBALL}`..."
-trap 'rm -vf ${TARBALL}' INT
+echo "Creating $(basename "$TARBALL")..."
+trap 'rm -vf "$TARBALL"' INT
+# XZ_OPTIONS and XZ_THREADS DEPEND on word splitting, so don't disable it here:
+# shellcheck disable=SC2086
 cd ../ &&
-  git archive --prefix=${DIR}/ --format=tar ${GITID} | xz ${XZ_OPTIONS} ${XZ_THREADS} > ${TARBALL};
+  git archive --prefix="$DIR"/ --format=tar "$GITID" | xz $XZ_OPTIONS $XZ_THREADS > "$TARBALL";
-- 
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