Skip to content

Commit

Permalink
fix: shellcheck 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LaszloGombos committed Dec 30, 2022
1 parent 94dcac7 commit 08b63a2
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 65 deletions.
2 changes: 1 addition & 1 deletion dracut-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ fs_get_option() {
while [ $# -gt 0 ]; do
case $1 in
$_option=*)
echo "${1#${_option}=}"
echo "${1#"${_option}"=}"
break
;;
esac
Expand Down
8 changes: 4 additions & 4 deletions dracut-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ inst_rules_wildcard() {
# make sure that library links are correct and up to date
build_ld_cache() {
for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do
[[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}"
[[ -f $f ]] && inst_simple "${f#"$dracutsysrootdir"}"
done
if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then
if [[ $EUID == 0 ]]; then
Expand Down Expand Up @@ -696,16 +696,16 @@ inst_libdir_file() {
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ ${_f#$dracutsysrootdir} =~ $_pattern ]] || continue
[[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
[[ ${_f#"$dracutsysrootdir"} =~ $_pattern ]] || continue
[[ -e $_f ]] && _files+=("${_f#"$dracutsysrootdir"}")
done
done
done
else
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
[[ -e $_f ]] && _files+=("${_f#"$dracutsysrootdir"}")
done
done
done
Expand Down
5 changes: 3 additions & 2 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ if [[ $regenerate_all == "yes" ]]; then
for ((i = 0; i < len; i++)); do
case ${dracut_args[$i]} in
--regenerate-all | --parallel)
# shellcheck disable=SC2184
unset dracut_args["$i"]
;;
esac
Expand Down Expand Up @@ -999,7 +1000,7 @@ for i in $DRACUT_PATH; do
if [ -L "$dracutsysrootdir$i" ]; then
rl=$(readlink -f "$dracutsysrootdir$i")
fi
rl="${rl#$dracutsysrootdir}"
rl="${rl#"$dracutsysrootdir"}"
if [[ $NPATH != *:$rl* ]]; then
NPATH+=":$rl"
fi
Expand Down Expand Up @@ -2212,7 +2213,7 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
[[ -e $objectname || -L $objectname ]] || continue
if [[ -d $objectname ]] && [[ ! -L $objectname ]]; then
# objectname is a directory, let's compute the final directory name
object_destdir=${destdir}/${objectname#$src/}
object_destdir=${destdir}/${objectname#"$src"/}
if ! [[ -e $object_destdir ]]; then
# shellcheck disable=SC2174
mkdir -m 0755 -p "$object_destdir"
Expand Down
2 changes: 1 addition & 1 deletion modules.d/03modsign/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ install() {

for x in "$dracutsysrootdir"/lib/modules/keys/*; do
[[ ${x} == "$dracutsysrootdir/lib/modules/keys/*" ]] && break
inst_simple "${x#$dracutsysrootdir}"
inst_simple "${x#"$dracutsysrootdir"}"
done
}
4 changes: 2 additions & 2 deletions modules.d/10i18n/console_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set_keyboard() {
}

set_terminal() {
local dev=$1
local dev="$1"

if [ "${UNICODE}" = 1 ]; then
printf '\033%%G' >&7
Expand Down Expand Up @@ -58,7 +58,7 @@ dev_close() {
}

dev_open() {
local dev=$1
local dev="$1"

exec 6< "${dev}" \
&& exec 7>> "${dev}"
Expand Down
4 changes: 2 additions & 2 deletions modules.d/35network-legacy/dhclient-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ setup_interface() {
fi
# Note: hostname can be fqdn OR short hostname, so chop off any
# trailing domain name and explicity add any domain if set.
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
[ -n "$hostname" ] && echo "echo ${hostname%."$domain"}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
}

setup_interface6() {
Expand Down Expand Up @@ -105,7 +105,7 @@ setup_interface6() {

# Note: hostname can be fqdn OR short hostname, so chop off any
# trailing domain name and explicity add any domain if set.
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
[ -n "$hostname" ] && echo "echo ${hostname%."$domain"}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
}

parse_option_121() {
Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-legacy/parse-bond.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# We translate list of slaves to space-separated here to make it easier to loop over them in ifup
# Ditto for bonding options
parsebond() {
local v=${1}:
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-legacy/parse-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

parsebridge() {
local v=${1}:
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-legacy/parse-ip-opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fi

# This ensures that BOOTDEV is always first in IFACES
if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ]; then
IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
IFACES="${IFACES%"$BOOTDEV"*} ${IFACES#*"$BOOTDEV"}"
IFACES="$BOOTDEV $IFACES"
fi

Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-legacy/parse-team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

parseteam() {
local v=${1}:
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-legacy/parse-vlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

parsevlan() {
local v=${1}:
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
Expand Down
16 changes: 8 additions & 8 deletions modules.d/40network/net-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ set_ifname() {

# pxelinux provides macaddr '-' separated, but we need ':'
fix_bootif() {
local macaddr=${1}
local macaddr="${1}"
local IFS='-'
# shellcheck disable=SC2086
macaddr=$(printf '%s:' ${macaddr})
Expand Down Expand Up @@ -395,11 +395,11 @@ parse_iscsi_root() {
iscsi_target_ip=${v#[[]}
iscsi_target_ip=${iscsi_target_ip%%[]]*}
# shellcheck disable=SC1087
v=${v#[[]$iscsi_target_ip[]]:}
v=${v#[[]"$iscsi_target_ip"[]]:}
;;
*)
iscsi_target_ip=${v%%[:]*}
v=${v#$iscsi_target_ip:}
v=${v#"$iscsi_target_ip":}
;;
esac

Expand Down Expand Up @@ -467,7 +467,7 @@ parse_iscsi_root() {
}

ip_to_var() {
local v=${1}:
local v="${1}":
local i
set --
while [ -n "$v" ]; do
Expand All @@ -476,7 +476,7 @@ ip_to_var() {
i="${v%%\]:*}"
i="${i##\[}"
set -- "$@" "$i"
v=${v#\[$i\]:}
v=${v#\["$i"\]:}
else
set -- "$@" "${v%%:*}"
v=${v#*:}
Expand Down Expand Up @@ -565,7 +565,7 @@ ip_to_var() {
}

route_to_var() {
local v=${1}:
local v="${1}":
local i
set --
while [ -n "$v" ]; do
Expand All @@ -574,7 +574,7 @@ route_to_var() {
i="${v%%\]:*}"
i="${i##\[}"
set -- "$@" "$i"
v=${v#\[$i\]:}
v=${v#\["$i"\]:}
else
set -- "$@" "${v%%:*}"
v=${v#*:}
Expand Down Expand Up @@ -691,7 +691,7 @@ wait_for_route_ok() {

while [ $cnt -lt $timeout ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
[ -n "$li" ] && [ -z "${li##*"$1"*}" ] && return 0
sleep 0.1
cnt=$((cnt + 1))
done
Expand Down
4 changes: 2 additions & 2 deletions modules.d/45url-lib/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ install() {
done
if [[ $_found ]] && [[ -n $_crts ]]; then
for _crt in $_crts; do
if ! inst "${_crt#$dracutsysrootdir}"; then
if ! inst "${_crt#"$dracutsysrootdir"}"; then
dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work."
continue
fi
Expand Down Expand Up @@ -78,7 +78,7 @@ install() {
# install everything in it
mkdir -p -- "${initdir}/${_p11root}"
if ! $DRACUT_CP -L -t "${initdir}/${_p11root}" "${dracutsysrootdir}${_p11root}"/*; then
dwarn "Couldn't install from p11-kit trust dir '${_p11root#$dracutsysrootdir}'; HTTPS might not work."
dwarn "Couldn't install from p11-kit trust dir '${_p11root#"$dracutsysrootdir"}'; HTTPS might not work."
fi
done
done
Expand Down
2 changes: 1 addition & 1 deletion modules.d/45url-lib/url-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ nfs_already_mounted() {
if [ "$path" = "$p" ]; then
echo "$mnt"
elif str_starts "$path" "$p"; then
echo "$mnt"/"${path#$p/}"
echo "$mnt"/"${path#"$p"/}"
fi
fi
done < /proc/mounts
Expand Down
4 changes: 2 additions & 2 deletions modules.d/50plymouth/plymouth-populate-initrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ if [[ $hostonly ]]; then
else
for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/*; do
[[ -f $x ]] || continue
THEME_DIR=$(dirname "${x#$dracutsysrootdir}")
THEME_DIR=$(dirname "${x#"$dracutsysrootdir"}")
# shellcheck disable=SC2174
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
inst_multiple "${x#$dracutsysrootdir}"
inst_multiple "${x#"$dracutsysrootdir"}"
done
(
cd "${initdir}"/usr/share/plymouth/themes || exit
Expand Down
2 changes: 1 addition & 1 deletion modules.d/90crypt/crypt-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ ask_for_password() {
# example:
# test_dev -f LABEL="nice label" /some/file1
test_dev() {
local test_op=$1
local test_op="$1"
local dev="$2"
local f="$3"
local ret=1
Expand Down
6 changes: 3 additions & 3 deletions modules.d/90crypt/parse-crypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ else

uuid=${uuid##luks-}
if luksname=$(_cryptgetargsname "$uuid="); then
luksname="${luksname#$uuid=}"
luksname="${luksname#"$uuid"=}"
else
luksname="luks-$uuid"
fi
Expand Down Expand Up @@ -93,7 +93,7 @@ else

serialid=${serialid##luks-}
if luksname=$(_cryptgetargsname "$serialid="); then
luksname="${luksname#$serialid=}"
luksname="${luksname#"$serialid"=}"
else
luksname="luks-$serialid"
fi
Expand Down Expand Up @@ -133,7 +133,7 @@ else

luksid=${luksid##luks-}
if luksname=$(_cryptgetargsname "$luksid="); then
luksname="${luksname#$luksid=}"
luksname="${luksname#"$luksid"=}"
else
luksname="luks-$luksid"
fi
Expand Down
4 changes: 2 additions & 2 deletions modules.d/90dm/dm-shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

_remove_dm() {
local dev=$1
local dev="$1"
local s
local devname

Expand All @@ -26,7 +26,7 @@ _remove_dm() {

_do_dm_shutdown() {
local ret=0
local final=$1
local final="$1"
local dev

info "Disassembling device-mapper devices"
Expand Down
2 changes: 1 addition & 1 deletion modules.d/90dmraid/dmraid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
# only activate specified DM RAIDS
for r in $DM_RAIDS; do
for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then
if [ "${s##"$r"}" != "$s" ]; then
info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
fi
Expand Down
2 changes: 1 addition & 1 deletion modules.d/90mdraid/md-shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

_do_md_shutdown() {
local ret
local final=$1
local final="$1"
info "Waiting for mdraid devices to be clean."
mdadm -vv --wait-clean --scan | vinfo
ret=$?
Expand Down
8 changes: 4 additions & 4 deletions modules.d/95lunmask/parse-lunmask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh

create_udev_rule() {
local transport=$1
local tgtid=$2
local lun=$3
local _rule=/etc/udev/rules.d/51-${transport}-lunmask-${tgtid}.rules
local transport="$1"
local tgtid="$2"
local lun="$3"
local _rule=/etc/udev/rules.d/51-"${transport}"-lunmask-"${tgtid}".rules

[ -e "${_rule}" ] && return 0

Expand Down
4 changes: 2 additions & 2 deletions modules.d/98dracut-systemd/rootfs-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ EOF
}

generator_mount_rootfs() {
local _type=$2
local _flags=$3
local _type="$2"
local _flags="$3"
local _name

[ -z "$1" ] && return 0
Expand Down
6 changes: 3 additions & 3 deletions modules.d/98syslog/rsyslogd-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ if [ -f /var/run/syslogd.pid ]; then
fi

rsyslog_config() {
local server=$1
local server="$1"
shift
local syslog_template=$1
local syslog_template="$1"
shift
local filters=$*
local filters="$*"
local filter=

cat "$syslog_template"
Expand Down
6 changes: 3 additions & 3 deletions modules.d/98usrmount/mount-usr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ filtersubvol() {
}

fsck_usr() {
local _dev=$1
local _fs=$2
local _fsopts=$3
local _dev="$1"
local _fs="$2"
local _fsopts="$3"
local _fsckoptions

if [ -f "$NEWROOT"/fsckoptions ]; then
Expand Down
Loading

0 comments on commit 08b63a2

Please sign in to comment.