From b40fb2ae53427e0fb14514e7929c02246ac298f0 Mon Sep 17 00:00:00 2001
From: nl6720 <nl6720@gmail.com>
Date: Thu, 16 Jul 2020 15:49:23 +0300
Subject: [PATCH] Separate custom comments from shellcheck comments

Having a shellcheck directive and custom comments in the same line can trigger SC1107 on old versions of shellcheck.
---
 archiso/initcpio/hooks/archiso            | 15 ++++++++++-----
 archiso/initcpio/hooks/archiso_loop_mnt   |  9 ++++++---
 archiso/initcpio/hooks/archiso_pxe_common |  9 ++++++---
 archiso/initcpio/hooks/archiso_pxe_http   | 15 ++++++++++-----
 archiso/initcpio/hooks/archiso_pxe_nbd    |  3 ++-
 archiso/initcpio/hooks/archiso_pxe_nfs    |  6 ++++--
 6 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso
index 44abb886..7f2f9a7e 100644
--- a/archiso/initcpio/hooks/archiso
+++ b/archiso/initcpio/hooks/archiso
@@ -63,7 +63,8 @@ _mnt_sfs() {
     local img_fullname="${img##*/}"
     local sfs_dev
 
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${copytoram}" = "y" ]; then
         msg -n ":: Copying squashfs image to RAM..."
         if ! cp -- "${img}" "/run/archiso/copytoram/${img_fullname}" ; then
@@ -129,10 +130,12 @@ run_hook() {
     [ -z "${copytoram_size}" ] && copytoram_size="75%"
     [ -z "${archisobasedir}" ] && archisobasedir="arch"
     [ -z "${dm_snap_prefix}" ] && dm_snap_prefix="arch"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     [ -z "${archisodevice}" ] && archisodevice="/dev/disk/by-label/${archisolabel}"
     [ -z "${cow_spacesize}" ] && cow_spacesize="256M"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${cow_label}" ]; then
         cow_device="/dev/disk/by-label/${cow_label}"
         [ -z "${cow_persistent}" ] && cow_persistent="P"
@@ -163,7 +166,8 @@ archiso_mount_handler() {
         fi
     fi
 
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${checksum}" = "y" ]; then
         if [ -f "/run/archiso/bootmnt/${archisobasedir}/${arch}/airootfs.sha512" ]; then
             msg -n ":: Self-test requested, please wait..."
@@ -180,7 +184,8 @@ archiso_mount_handler() {
         fi
     fi
 
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${verify}" = "y" ]; then
         if [ -f "/run/archiso/bootmnt/${archisobasedir}/${arch}/airootfs.sfs.sig" ]; then
             msg -n ":: Signature verification requested, please wait..."
diff --git a/archiso/initcpio/hooks/archiso_loop_mnt b/archiso/initcpio/hooks/archiso_loop_mnt
index c32a544f..2c607f50 100644
--- a/archiso/initcpio/hooks/archiso_loop_mnt
+++ b/archiso/initcpio/hooks/archiso_loop_mnt
@@ -1,10 +1,12 @@
 #!/bin/ash
 
 run_hook () {
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     [ -n "${img_label}" ] && img_dev="/dev/disk/by-label/${img_label}"
     [ -z "${img_flags}" ] && img_flags="defaults"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${img_dev}" ] && [ -n "${img_loop}" ]; then
         export mount_handler="archiso_loop_mount_handler"
     fi
@@ -17,7 +19,8 @@ archiso_loop_mount_handler () {
 
     msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}"
     _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" "${img_flags}"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${copytoram}" != "y" ]; then
         readlink -f "${img_dev}" >> /run/archiso/used_block_devices
     fi
diff --git a/archiso/initcpio/hooks/archiso_pxe_common b/archiso/initcpio/hooks/archiso_pxe_common
index e31903e9..bf8e8838 100644
--- a/archiso/initcpio/hooks/archiso_pxe_common
+++ b/archiso/initcpio/hooks/archiso_pxe_common
@@ -11,7 +11,8 @@ run_hook () {
     if [ -n "${ip}" ]; then
         if [ -n "${BOOTIF}" ]; then
             bootif_mac="${BOOTIF#01-}"
-            # shellcheck disable=SC2169 # ash supports bash-like string replacment
+            # shellcheck disable=SC2169
+            # ash supports bash-like string replacment
             bootif_mac="${bootif_mac//-/:}"
             for i in /sys/class/net/*/address; do
                 read -r net_mac < "${i}"
@@ -36,7 +37,8 @@ run_hook () {
             launch_interactive_shell
         fi
 
-        # shellcheck disable=SC1090 # ipconfig generates these files
+        # shellcheck disable=SC1090
+        # ipconfig generates these files
         . /tmp/net-*.conf
 
         export pxeserver="${ROOTSERVER}"
@@ -60,7 +62,8 @@ run_latehook () {
     if [ -n "${ip}" ]; then
         [ -z "${copy_resolvconf}" ] && copy_resolvconf="y"
 
-        # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+        # shellcheck disable=SC2154
+        # defined via initcpio's parse_cmdline()
         if [ "${copytoram}" = "y" ]; then
             if [ -n "${bootif_dev}" ]; then
                 ip addr flush dev "${bootif_dev}"
diff --git a/archiso/initcpio/hooks/archiso_pxe_http b/archiso/initcpio/hooks/archiso_pxe_http
index 5e55356d..bf2f5f40 100644
--- a/archiso/initcpio/hooks/archiso_pxe_http
+++ b/archiso/initcpio/hooks/archiso_pxe_http
@@ -1,7 +1,8 @@
 #!/bin/ash
 
 run_hook() {
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${ip}" ] && [ -n "${archiso_http_srv}" ]; then
 
         # booting with http is always copy-to-ram, so set here to make sure
@@ -24,7 +25,8 @@ _curl_get() {
     local _dst="${2}"
 
     msg ":: Downloading '${_url}'"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if ! curl -L -f -o "/run/archiso/httpspace/${archisobasedir}${_dst}/${_url##*/}" --create-dirs "${_url}"; then
         echo "ERROR: Downloading '${_url}'"
         echo "   Falling back to interactive prompt"
@@ -40,14 +42,17 @@ archiso_pxe_http_mount_handler () {
     mkdir -p "/run/archiso/httpspace"
     mount -t tmpfs -o size="${archiso_http_spc}",mode=0755 httpspace "/run/archiso/httpspace"
 
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     _curl_get "${archiso_http_srv}${archisobasedir}/${arch}/airootfs.sfs" "/${arch}"
 
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${checksum}" = "y" ]; then
         _curl_get "${archiso_http_srv}${archisobasedir}/${arch}/airootfs.sha512" "/${arch}"
     fi
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ "${verify}" = "y" ]; then
         _curl_get "${archiso_http_srv}${archisobasedir}/${arch}/airootfs.sfs.sig" "/${arch}"
     fi
diff --git a/archiso/initcpio/hooks/archiso_pxe_nbd b/archiso/initcpio/hooks/archiso_pxe_nbd
index ce93080c..4ccbcbf4 100644
--- a/archiso/initcpio/hooks/archiso_pxe_nbd
+++ b/archiso/initcpio/hooks/archiso_pxe_nbd
@@ -1,7 +1,8 @@
 #!/bin/ash
 
 run_earlyhook() {
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${ip}" ] && [ -n "${archiso_nbd_srv}" ]; then
         # Module autoloading like with loop devices does not work, doing manually...
         modprobe nbd 2> /dev/null
diff --git a/archiso/initcpio/hooks/archiso_pxe_nfs b/archiso/initcpio/hooks/archiso_pxe_nfs
index 406541b3..be1e4c35 100644
--- a/archiso/initcpio/hooks/archiso_pxe_nfs
+++ b/archiso/initcpio/hooks/archiso_pxe_nfs
@@ -1,7 +1,8 @@
 #!/bin/ash
 
 run_hook() {
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${ip}" ] && [ -n "${archiso_nfs_srv}" ]; then
 
         archiso_nfs_srv=$(eval echo "${archiso_nfs_srv}")
@@ -15,7 +16,8 @@ archiso_nfs_mount_handler() {
     newroot="${1}"
     mkdir -p "/run/archiso/bootmnt"
     msg ":: Mounting '${archiso_nfs_srv}'"
-    # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+    # shellcheck disable=SC2154
+    # defined via initcpio's parse_cmdline()
     if [ -n "${archiso_nfs_opt}" ]; then
         nfsmount -o "${archiso_nfs_opt}" "${archiso_nfs_srv}" "/run/archiso/bootmnt"
         mount_status=$?
-- 
GitLab