more shellcheck fixes
This commit is contained in:
parent
ef1165de3c
commit
dd01d03775
@ -1,4 +1,11 @@
|
|||||||
# vim: set ft=sh:
|
# vim: set ft=sh:
|
||||||
|
# shellcheck shell=sh
|
||||||
|
#
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2154
|
||||||
|
#
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2086
|
||||||
#
|
#
|
||||||
# handle_luks()
|
# handle_luks()
|
||||||
{
|
{
|
||||||
@ -18,8 +25,6 @@
|
|||||||
# see https://bugs.archlinux.org/task/56771
|
# see https://bugs.archlinux.org/task/56771
|
||||||
[ -e /lib/libgcc_s.so.1 ] && copy_library /lib/libgcc_s.so.1
|
[ -e /lib/libgcc_s.so.1 ] && copy_library /lib/libgcc_s.so.1
|
||||||
|
|
||||||
# word splitting is safe by design
|
|
||||||
# shellcheck disable=2086
|
|
||||||
IFS=,; set -- $luks_opts; unset IFS
|
IFS=,; set -- $luks_opts; unset IFS
|
||||||
|
|
||||||
set -C; for opt; do case "${opt%%=*}" in
|
set -C; for opt; do case "${opt%%=*}" in
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# vim: set ft=sh:
|
# vim: set ft=sh:
|
||||||
|
# shellcheck shell=sh
|
||||||
|
#
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2154
|
||||||
|
#
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2086,2068
|
||||||
#
|
#
|
||||||
# unlock_luks()
|
# unlock_luks()
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# vim: set ft=sh:
|
# vim: set ft=sh:
|
||||||
|
# shellcheck shell=sh
|
||||||
|
#
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2154
|
||||||
|
#
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2086
|
||||||
#
|
#
|
||||||
# handle_lvm()
|
# handle_lvm()
|
||||||
{
|
{
|
||||||
@ -26,8 +33,6 @@
|
|||||||
use_lvmetad = 0
|
use_lvmetad = 0
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# word splitting is safe by design
|
|
||||||
# shellcheck disable=2086
|
|
||||||
IFS=,; set -- $lvm_opts; unset IFS
|
IFS=,; set -- $lvm_opts; unset IFS
|
||||||
|
|
||||||
for opt; do case "$opt" in
|
for opt; do case "$opt" in
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# vim: set ft=sh:
|
# vim: set ft=sh:
|
||||||
|
# shellcheck shell=sh
|
||||||
|
#
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2154
|
||||||
|
#
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2086,2068
|
||||||
#
|
#
|
||||||
# trigger_lvm()
|
# trigger_lvm()
|
||||||
{
|
{
|
||||||
|
10
init
10
init
@ -2,6 +2,8 @@
|
|||||||
#
|
#
|
||||||
# tiny init
|
# tiny init
|
||||||
#
|
#
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2154
|
||||||
|
|
||||||
print()
|
print()
|
||||||
{
|
{
|
||||||
@ -40,6 +42,8 @@ run_hook()
|
|||||||
type="$1"; hksdir=/usr/share/tinyramfs/hooks
|
type="$1"; hksdir=/usr/share/tinyramfs/hooks
|
||||||
|
|
||||||
# run hooks if any
|
# run hooks if any
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=1090
|
||||||
for hook in $hooks; do
|
for hook in $hooks; do
|
||||||
[ -f "${hksdir}/${hook}/${hook}.${type}" ] || continue
|
[ -f "${hksdir}/${hook}/${hook}.${type}" ] || continue
|
||||||
. "${hksdir}/${hook}/${hook}.${type}"
|
. "${hksdir}/${hook}/${hook}.${type}"
|
||||||
@ -48,6 +52,8 @@ run_hook()
|
|||||||
|
|
||||||
prepare_environment()
|
prepare_environment()
|
||||||
{
|
{
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=1091
|
||||||
. /etc/tinyramfs/config
|
. /etc/tinyramfs/config
|
||||||
|
|
||||||
export \
|
export \
|
||||||
@ -118,6 +124,8 @@ mount_root()
|
|||||||
"${rorw:--o ro}${root_opts:+,$root_opts}" \
|
"${rorw:--o ro}${root_opts:+,$root_opts}" \
|
||||||
"${root_type:+-t $root_type}" "$device" "/mnt/root"
|
"${root_type:+-t $root_type}" "$device" "/mnt/root"
|
||||||
|
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2068
|
||||||
mount $@ || panic "failed to mount root"
|
mount $@ || panic "failed to mount root"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +146,8 @@ boot_system()
|
|||||||
|
|
||||||
# POSIX exec has no -c flag to execute command with empty environment
|
# POSIX exec has no -c flag to execute command with empty environment
|
||||||
# use 'env -i' to prevent leaking exported variables
|
# use 'env -i' to prevent leaking exported variables
|
||||||
|
# word splitting is safe by design
|
||||||
|
# shellcheck disable=2068
|
||||||
exec env -i \
|
exec env -i \
|
||||||
TERM=linux \
|
TERM=linux \
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin \
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin \
|
||||||
|
30
tinyramfs
30
tinyramfs
@ -86,7 +86,7 @@ prepare_environment()
|
|||||||
|
|
||||||
# false positive
|
# false positive
|
||||||
# shellcheck disable=1090
|
# shellcheck disable=1090
|
||||||
. "${config:-/etc/tinyramfs/config}"
|
. "${config:=/etc/tinyramfs/config}"
|
||||||
|
|
||||||
: "${kernel:=$(uname -r)}"
|
: "${kernel:=$(uname -r)}"
|
||||||
: "${moddir:=/lib/modules}"
|
: "${moddir:=/lib/modules}"
|
||||||
@ -96,8 +96,8 @@ prepare_environment()
|
|||||||
mkdir -p "${tmpdir:=${TMPDIR:-/tmp}/tinyramfs.$$}"
|
mkdir -p "${tmpdir:=${TMPDIR:-/tmp}/tinyramfs.$$}"
|
||||||
|
|
||||||
# false positive
|
# false positive
|
||||||
# shellcheck disable=2015,2064
|
# shellcheck disable=2015
|
||||||
[ "$debug" = 1 ] && set -x || trap "rm -rf $tmpdir" EXIT INT
|
[ "$debug" = 1 ] && set -x || trap 'rm -rf $tmpdir' EXIT INT
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_initramfs()
|
prepare_initramfs()
|
||||||
@ -150,18 +150,18 @@ copy_binary()
|
|||||||
binary=$(command -v "$1")
|
binary=$(command -v "$1")
|
||||||
|
|
||||||
# check if binary exist and builtin
|
# check if binary exist and builtin
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=2086
|
||||||
case "$binary" in */*) ;;
|
case "$binary" in */*) ;;
|
||||||
"")
|
"")
|
||||||
panic "$1 does not exist"
|
panic "$1 does not exist"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# word splitting is safe by design
|
|
||||||
# shellcheck disable=2086
|
|
||||||
IFS=:; set -- $PATH; unset IFS
|
IFS=:; set -- $PATH; unset IFS
|
||||||
|
|
||||||
# assume that `command -v` returned builtin command.
|
# assume that `command -v` returned builtin command.
|
||||||
# this behavior depends on shell implementation.
|
# this behavior depends on shell implementation.
|
||||||
# to be independented we simply iterating over PATH
|
# to be independent we simply iterating over PATH
|
||||||
# to find external alternative ( e.g kill => /bin/kill )
|
# to find external alternative ( e.g kill => /bin/kill )
|
||||||
for _dir; do
|
for _dir; do
|
||||||
[ -x "${_dir}/${binary}" ] || ! continue
|
[ -x "${_dir}/${binary}" ] || ! continue
|
||||||
@ -249,25 +249,25 @@ copy_hook()
|
|||||||
{
|
{
|
||||||
hook="$1"
|
hook="$1"
|
||||||
|
|
||||||
|
# false positive
|
||||||
|
# shellcheck disable=1090
|
||||||
for _dir in "$hksdir" /etc/tinyramfs/hooks /usr/share/tinyramfs/hooks; do
|
for _dir in "$hksdir" /etc/tinyramfs/hooks /usr/share/tinyramfs/hooks; do
|
||||||
[ -f "${_dir}/${hook}/${hook}" ] || ! continue
|
[ -f "${_dir}/${hook}/${hook}" ] || ! continue
|
||||||
|
|
||||||
print "running $hook hook"; . "${_dir}/${hook}/${hook}"
|
print "running $hook hook"; . "${_dir}/${hook}/${hook}"
|
||||||
|
|
||||||
if [ -f "${_dir}/${hook}/${hook}.init" ]; then
|
for _file in init init.early; do
|
||||||
mkdir -p "${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
[ -f "${_dir}/${hook}/${hook}.${_file}" ] || continue
|
||||||
cp "${_dir}/${hook}/${hook}.init" \
|
|
||||||
"${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "${_dir}/${hook}/${hook}.init.early" ]; then
|
{
|
||||||
mkdir -p "${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
mkdir -p "${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
||||||
cp "${_dir}/${hook}/${hook}.init.early" \
|
cp "${_dir}/${hook}/${hook}.${_file}" \
|
||||||
"${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
"${tmpdir}/usr/share/tinyramfs/hooks/${hook##*/}"
|
||||||
fi || panic
|
} || panic
|
||||||
|
done
|
||||||
|
|
||||||
break
|
break
|
||||||
done || panic "could not run $hook"
|
done || panic "could not run $hook hook"
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_modules()
|
copy_modules()
|
||||||
|
Loading…
Reference in New Issue
Block a user