git » kxd » commit cc1b865

Add missing variable quoting on shell scripts

author Alberto Bertogli
2024-10-04 11:36:56 UTC
committer Alberto Bertogli
2024-10-04 11:44:03 UTC
parent 5159f22ff9a8a232fcae8a5ae5000c57ab41807d

Add missing variable quoting on shell scripts

This patch adds some missing variable quoting to our shell scripts, as
detected by shellcheck.

cryptsetup/initramfs-hooks/kxc +1 -1
cryptsetup/kxc-cryptsetup +4 -4
doc/man/generate.sh +5 -5
tests/cover.sh +1 -1

diff --git a/cryptsetup/initramfs-hooks/kxc b/cryptsetup/initramfs-hooks/kxc
index 217bc0e..6bd1760 100755
--- a/cryptsetup/initramfs-hooks/kxc
+++ b/cryptsetup/initramfs-hooks/kxc
@@ -25,5 +25,5 @@ copy_exec /usr/bin/kxc /bin
 
 # Install the configuration into initramfs (if it exists).
 if [ -d /etc/kxc/ ]; then
-	cp -a /etc/kxc/ ${DESTDIR}/etc
+	cp -a /etc/kxc/ "${DESTDIR}/etc"
 fi
diff --git a/cryptsetup/kxc-cryptsetup b/cryptsetup/kxc-cryptsetup
index 7ccfc49..9cad2e9 100755
--- a/cryptsetup/kxc-cryptsetup
+++ b/cryptsetup/kxc-cryptsetup
@@ -22,8 +22,8 @@ for KXC in /bin/kxc /sbin/kxc /usr/bin/kxc /usr/sbin/kxc; do
 done
 
 exec $KXC \
-	--client_cert=$CLIENT_CERT \
-	--client_key=$CLIENT_KEY \
-	--server_cert=$SERVER_CERT \
-	$SERVER_URL
+	"--client_cert=$CLIENT_CERT" \
+	"--client_key=$CLIENT_KEY" \
+	"--server_cert=$SERVER_CERT" \
+	"$SERVER_URL"
 
diff --git a/doc/man/generate.sh b/doc/man/generate.sh
index 2f29a58..615d18b 100755
--- a/doc/man/generate.sh
+++ b/doc/man/generate.sh
@@ -8,20 +8,20 @@
 set -e
 
 for IN in *.pod; do
-	OUT=$( basename $IN .pod )
+	OUT=$( basename "$IN" .pod )
 	SECTION=${OUT##*.}
 	NAME=${OUT%.*}
 
 	# If it has not changed in git, set the mtime to the last commit that
 	# touched the file.
 	CHANGED=$( git status --porcelain -- "$IN" | wc -l )
-	if [ $CHANGED -eq 0 ]; then
+	if [ "$CHANGED" -eq 0 ]; then
 		GIT_MTIME=$( git log --pretty=%at -n1 -- "$IN" )
 		touch -d "@$GIT_MTIME" "$IN"
 	fi
 
-	podchecker $IN
-	pod2man --section=$SECTION --name=$NAME \
+	podchecker "$IN"
+	pod2man "--section=$SECTION" "--name=$NAME" \
 		--release "" --center "" \
-		$IN $OUT
+		"$IN" "$OUT"
 done
diff --git a/tests/cover.sh b/tests/cover.sh
index 47927b7..1f970a7 100755
--- a/tests/cover.sh
+++ b/tests/cover.sh
@@ -2,7 +2,7 @@
 
 set -e
 
-cd "$(realpath `dirname ${0}`)/../"
+cd "$( realpath "$(dirname "${0}")" )/../"
 
 make GOFLAGS="-cover -covermode=count"