changeset 665:24129dd789f0

Shellcheck for rc-scripts
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 29 Sep 2024 18:30:22 +0200
parents 83e6237350e4
children 6fe22409e445
files .shellcheckrc files/fbhyve.in files/fwireguard.in
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.shellcheckrc	Sun Sep 29 17:55:06 2024 +0200
+++ b/.shellcheckrc	Sun Sep 29 18:30:22 2024 +0200
@@ -11,6 +11,7 @@
 
 source-path=SCRIPTDIR/../share/local-bsdtools
 source-path=SCRIPTDIR
+source-path=/etc
 external-sources=true
 
 # $/${} is unnecessary on arithmetic variables
--- a/files/fbhyve.in	Sun Sep 29 17:55:06 2024 +0200
+++ b/files/fbhyve.in	Sun Sep 29 18:30:22 2024 +0200
@@ -28,6 +28,9 @@
 #                             The default is $fbhyve_configdir/<vm>.conf
 #
 
+# shellcheck disable=SC2034,SC2154,SC2223
+
+# shellcheck disable=SC1094     # parsing fails: rc.subr contains unknown features
 . /etc/rc.subr
 
 name="fbhyve"
@@ -74,6 +77,7 @@
     _ec=0
     _swap=$*; shift; _vmarglist=$*
     _vmlist=${_vmarglist:-${fbhyve_list}}
+    # shellcheck disable=SC2086
     set -- ${_swap}
     for _vm in ${_vmlist}; do
         "$0" "$1" "${_vm}"
@@ -109,7 +113,7 @@
         _rc=1
     fi
 
-    if ${command} has-session -t ${_session} 2>/dev/null; then
+    if ${command} has-session -t "${_session}" 2>/dev/null; then
 	echo "tmux session ${_session} exists."
         if [ ${_rc} -gt 0 ]; then
             _rc=2
--- a/files/fwireguard.in	Sun Sep 29 17:55:06 2024 +0200
+++ b/files/fwireguard.in	Sun Sep 29 18:30:22 2024 +0200
@@ -19,6 +19,9 @@
 # NOTE: All wireguard interfaces must be mentioned fist in "cloned_interfaces".
 #
 
+# shellcheck disable=SC2034,SC2129,SC2223,SC3037
+
+# shellcheck disable=SC1094     # parsing fails: rc.subr contains unknown features
 . /etc/rc.subr
 
 name=fwireguard
@@ -61,7 +64,7 @@
         _f="${fwireguard_configdir}/${_if}.pub"
         if [ ! -f "${_f}" ]; then
             echo "Generating public key for ${_if} in ${_f}"
-            /usr/bin/wg pubkey < ${fwireguard_configdir}/${_if}.key > "${_f}"
+            /usr/bin/wg pubkey < "${fwireguard_configdir}/${_if}.key" > "${_f}"
         fi
 
         _f="${fwireguard_configdir}/${_if}.conf"