git: 7ad4d94d5bf2 - main - Fix some shell issues by adding quotes and replace backticks with $()

From: Benedict Reuschling <bcr_at_FreeBSD.org>
Date: Mon, 19 Jun 2023 11:07:36 UTC
The branch main has been updated by bcr:

URL: https://cgit.FreeBSD.org/src/commit/?id=7ad4d94d5bf275f745907d8bf4614219f5ce4d34

commit 7ad4d94d5bf275f745907d8bf4614219f5ce4d34
Author:     Benedict Reuschling <bcr@FreeBSD.org>
AuthorDate: 2023-06-19 11:03:06 +0000
Commit:     Benedict Reuschling <bcr@FreeBSD.org>
CommitDate: 2023-06-19 11:03:06 +0000

    Fix some shell issues by adding quotes and replace backticks with $()
    
    This patch fixes the following issues reported by shellcheck:
    - Quote default assignments (SC2223)
    - Use $() instead of backticks (SC2006)
    - Double quote $@ (SC2068)
    - Double quote variables in if-statements and other places (SC2086)
    
    While here, fix a whitespace at one end of line instance in the license
    text.
    
    Approved by:    manu
    Differential Revision: https://reviews.freebsd.org/D40604
---
 usr.sbin/fwget/fwget.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/fwget/fwget.sh b/usr.sbin/fwget/fwget.sh
index 2d5ad8adffd8..61acaee86687 100644
--- a/usr.sbin/fwget/fwget.sh
+++ b/usr.sbin/fwget/fwget.sh
@@ -7,7 +7,7 @@
 # Copyright 2023 Bjoern A. Zeeb
 #
 # Redistribution and use in source and binary forms, with or without
-# modification, are permitted providing that the following conditions 
+# modification, are permitted providing that the following conditions
 # are met:
 # 1. Redistributions of source code must retain the above copyright
 #    notice, this list of conditions and the following disclaimer.
@@ -27,12 +27,12 @@
 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-: ${LIBEXEC_PATH:="/usr/libexec/fwget"}
+: "${LIBEXEC_PATH:='/usr/libexec/fwget'}"
 
 usage()
 {
 	cat <<EOF
-Usage: `basename $0` [options] [subsystem]
+Usage: $(basename "$0") [options] [subsystem]
 
 Supported subsystems
   pci
@@ -46,7 +46,7 @@ EOF
 
 log()
 {
-	echo $@
+	echo "$@"
 }
 
 log_verbose()
@@ -55,7 +55,7 @@ log_verbose()
 		return
 	fi
 
-	echo $@
+	echo "$@"
 }
 
 addpkg()
@@ -99,15 +99,15 @@ fi
 
 # Fail early on unsupported subsystem
 for subsystem in ${subsystems}; do
-	if [ ! -f ${LIBEXEC_PATH}/${subsystem} ]; then
+	if [ ! -f "${LIBEXEC_PATH}"/"${subsystem}" ]; then
 		usage
 	fi
-	. ${LIBEXEC_PATH}/${subsystem}
+	. "${LIBEXEC_PATH}"/"${subsystem}"
 done
 
 packages=""
 for subsystem in ${subsystems}; do
-	${subsystem}_search_packages
+	"${subsystem}"_search_packages
 done
 
 case "${packages}" in
@@ -122,4 +122,4 @@ if [ "${DRY_RUN}" = "y" ]; then
 	exit 0
 fi
 
-pkg install -qy ${packages}
+pkg install -qy "${packages}"