From a23394e2a748e5745e325143b69834dab4c2abd6 Mon Sep 17 00:00:00 2001 From: Alexandr Savca Date: Tue, 22 Aug 2023 19:16:54 +0300 Subject: [PATCH] improve comments for shellcheck --- init | 13 ++++++++----- mkinitramfs.in | 26 +++++++++++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/init b/init index 8d14db5..d51f53b 100644 --- a/init +++ b/init @@ -80,8 +80,9 @@ run_hook() { local _HOOK local _HOOKTYPE="$1" + # Intentional: "can't follow non-constant source". # https://www.shellcheck.net/wiki/SC1090 - # shellcheck disable=1090 + # shellcheck disable=SC1090 for _HOOK in $hooks; do if [ -f "/usr/share/mkinitramfs/hooks/$_HOOK/$_HOOK.$_TYPE" ]; then . "/usr/share/mkinitramfs/hooks/$_HOOK/$_HOOK.$_TYPE" @@ -137,8 +138,9 @@ mount_root() { resolve_device "$root" "${root_wait:-$rootdelay}" + # Intentional word splitting. # https://www.shellcheck.net/wiki/SC2086 - # shellcheck disable=2086 + # shellcheck disable=SC2086 mount \ -o "${rorw:-ro}${root_opts:+,$root_opts}" \ ${root_type:+-t $root_type} \ @@ -168,9 +170,10 @@ boot_system() { # Some implementations of 'switch_root' doesn't conform to # POSIX utility guidelines and doesn't support '--'. This # means that safety of init_args isn't guaranteed. - # + + # Intentional word splitting. # https://shellcheck.net/wiki/SC2086 - # shellcheck disable=2086 + # shellcheck disable=SC2086 exec env -i TERM=linux PATH=/bin:/sbin:/usr/bin:/usr/sbin \ switch_root /mnt/root \ "${init-/sbin/init}" $init_args || @@ -188,7 +191,7 @@ trap panic EXIT # Read configuration. # https://www.shellcheck.net/wiki/SC1091 -# shellcheck disable=1091 +# shellcheck disable=SC1091 . /etc/mkinitramfs/config # Run init helpers. diff --git a/mkinitramfs.in b/mkinitramfs.in index bce4628..6a41782 100644 --- a/mkinitramfs.in +++ b/mkinitramfs.in @@ -4,7 +4,7 @@ # Intentional: "var is referenced but not assigned". # https://www.shellcheck.net/wiki/SC2154 -# shellcheck disable=2154 +# shellcheck disable=SC2154 # Intentional: allow "local"s declaration.a # https://www.shellcheck.net/wiki/SC3043 @@ -35,14 +35,14 @@ error() { # trap(1p) for more information. # https://www.shellcheck.net/wiki/SC2317 -# shellcheck disable=2317 +# shellcheck disable=SC2317 interrupted() { echo "" 1>&2 info "Aborted." 1>&2 exit 1 } -# shellcheck disable=2317 +# shellcheck disable=SC2317 atexit() { # clean up after ourselves if [ -d "$MKINITRAMFS_WORK_DIR" ]; then @@ -96,7 +96,7 @@ copy_file() { chmod "$_MODE" "$MKINITRAMFS_WORK_DIR/$_DEST" # https://www.shellcheck.net/wiki/SC2015 - # shellcheck disable=2015 + # shellcheck disable=SC2015 if [ "$_STRIP" = 1 ]; then strip "$MKINITRAMFS_WORK_DIR/$_DEST" >/dev/null 2>&1 || : fi @@ -115,9 +115,10 @@ copy_binary() { # empty -> do panic # external command -> do nothing # builtin command -> try to find external alternative - # + + # Intentional word splitting. # https://www.shellcheck.net/wiki/SC2086 - # shellcheck disable=2086 + # shellcheck disable=SC2086 case "$_BIN" in */*) ;; @@ -246,8 +247,9 @@ process_hooks() { # Run build-time hook. echo "+ $_HOOK" + # Intentional: "can't follow non-constant source". # https://www.shellcheck.net/wiki/SC1090 - # shellcheck disable=1090 + # shellcheck disable=SC1090 . "$_HOOKS_DIR/$_HOOK/$_HOOK" # Copy init-time hooks. @@ -317,8 +319,10 @@ copy_kernmodules() { "$KERNEL_MOD_DIR/$KERNEL_VERSION/kernel/drivers/usb/storage" \ -type f 2>/dev/null | while read -r _MOD || [ "$_MOD" ]; do - # Intentional. - # shellcheck disable=2295 + # Intentional pattern + # matching. + # https://www.shellcheck.net/wiki/SC2295 + # shellcheck disable=SC2295 copy_file "$_MOD" "/lib/modules/${_MOD#$KERNEL_MOD_DIR}" 644 0 done fi @@ -401,9 +405,9 @@ main() { # Read configuration. if [ -f "$MKINITRAMFS_CONF" ]; then - # Intentional. + # Intentional: "can't follow non-constant source". # https://www.shellcheck.net/wiki/SC1090 - # shellcheck disable=1090 + # shellcheck disable=SC1090 . "$MKINITRAMFS_CONF" else error "Missing configuration file '$MKINITRAMFS_CONF'"