Skip to content

Commit

Permalink
improve comments for shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
sighook committed Aug 22, 2023
1 parent 421b6f0 commit a23394e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
13 changes: 8 additions & 5 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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} \
Expand Down Expand Up @@ -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 ||
Expand All @@ -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.
Expand Down
26 changes: 15 additions & 11 deletions mkinitramfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
*/*)
;;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'"
Expand Down

0 comments on commit a23394e

Please sign in to comment.