Skip to content

Commit 08b63a2

Browse files
committed
fix: shellcheck 0.8.0
1 parent 94dcac7 commit 08b63a2

33 files changed

+68
-65
lines changed

dracut-functions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fs_get_option() {
712712
while [ $# -gt 0 ]; do
713713
case $1 in
714714
$_option=*)
715-
echo "${1#${_option}=}"
715+
echo "${1#"${_option}"=}"
716716
break
717717
;;
718718
esac

dracut-init.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ inst_rules_wildcard() {
573573
# make sure that library links are correct and up to date
574574
build_ld_cache() {
575575
for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do
576-
[[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}"
576+
[[ -f $f ]] && inst_simple "${f#"$dracutsysrootdir"}"
577577
done
578578
if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then
579579
if [[ $EUID == 0 ]]; then
@@ -696,16 +696,16 @@ inst_libdir_file() {
696696
for _dir in $libdirs; do
697697
for _i in "$@"; do
698698
for _f in "$dracutsysrootdir$_dir"/$_i; do
699-
[[ ${_f#$dracutsysrootdir} =~ $_pattern ]] || continue
700-
[[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
699+
[[ ${_f#"$dracutsysrootdir"} =~ $_pattern ]] || continue
700+
[[ -e $_f ]] && _files+=("${_f#"$dracutsysrootdir"}")
701701
done
702702
done
703703
done
704704
else
705705
for _dir in $libdirs; do
706706
for _i in "$@"; do
707707
for _f in "$dracutsysrootdir$_dir"/$_i; do
708-
[[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
708+
[[ -e $_f ]] && _files+=("${_f#"$dracutsysrootdir"}")
709709
done
710710
done
711711
done

dracut.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ if [[ $regenerate_all == "yes" ]]; then
958958
for ((i = 0; i < len; i++)); do
959959
case ${dracut_args[$i]} in
960960
--regenerate-all | --parallel)
961+
# shellcheck disable=SC2184
961962
unset dracut_args["$i"]
962963
;;
963964
esac
@@ -999,7 +1000,7 @@ for i in $DRACUT_PATH; do
9991000
if [ -L "$dracutsysrootdir$i" ]; then
10001001
rl=$(readlink -f "$dracutsysrootdir$i")
10011002
fi
1002-
rl="${rl#$dracutsysrootdir}"
1003+
rl="${rl#"$dracutsysrootdir"}"
10031004
if [[ $NPATH != *:$rl* ]]; then
10041005
NPATH+=":$rl"
10051006
fi
@@ -2212,7 +2213,7 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
22122213
[[ -e $objectname || -L $objectname ]] || continue
22132214
if [[ -d $objectname ]] && [[ ! -L $objectname ]]; then
22142215
# objectname is a directory, let's compute the final directory name
2215-
object_destdir=${destdir}/${objectname#$src/}
2216+
object_destdir=${destdir}/${objectname#"$src"/}
22162217
if ! [[ -e $object_destdir ]]; then
22172218
# shellcheck disable=SC2174
22182219
mkdir -m 0755 -p "$object_destdir"

modules.d/03modsign/module-setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ install() {
3333

3434
for x in "$dracutsysrootdir"/lib/modules/keys/*; do
3535
[[ ${x} == "$dracutsysrootdir/lib/modules/keys/*" ]] && break
36-
inst_simple "${x#$dracutsysrootdir}"
36+
inst_simple "${x#"$dracutsysrootdir"}"
3737
done
3838
}

modules.d/10i18n/console_init.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set_keyboard() {
1919
}
2020

2121
set_terminal() {
22-
local dev=$1
22+
local dev="$1"
2323

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

6060
dev_open() {
61-
local dev=$1
61+
local dev="$1"
6262

6363
exec 6< "${dev}" \
6464
&& exec 7>> "${dev}"

modules.d/35network-legacy/dhclient-script.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ setup_interface() {
7272
fi
7373
# Note: hostname can be fqdn OR short hostname, so chop off any
7474
# trailing domain name and explicity add any domain if set.
75-
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
75+
[ -n "$hostname" ] && echo "echo ${hostname%."$domain"}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
7676
}
7777

7878
setup_interface6() {
@@ -105,7 +105,7 @@ setup_interface6() {
105105

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

111111
parse_option_121() {

modules.d/35network-legacy/parse-bond.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# We translate list of slaves to space-separated here to make it easier to loop over them in ifup
1616
# Ditto for bonding options
1717
parsebond() {
18-
local v=${1}:
18+
local v="${1}":
1919
set --
2020
while [ -n "$v" ]; do
2121
set -- "$@" "${v%%:*}"

modules.d/35network-legacy/parse-bridge.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99

1010
parsebridge() {
11-
local v=${1}:
11+
local v="${1}":
1212
set --
1313
while [ -n "$v" ]; do
1414
set -- "$@" "${v%%:*}"

modules.d/35network-legacy/parse-ip-opts.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fi
139139

140140
# This ensures that BOOTDEV is always first in IFACES
141141
if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ]; then
142-
IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
142+
IFACES="${IFACES%"$BOOTDEV"*} ${IFACES#*"$BOOTDEV"}"
143143
IFACES="$BOOTDEV $IFACES"
144144
fi
145145

modules.d/35network-legacy/parse-team.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111

1212
parseteam() {
13-
local v=${1}:
13+
local v="${1}":
1414
set --
1515
while [ -n "$v" ]; do
1616
set -- "$@" "${v%%:*}"

modules.d/35network-legacy/parse-vlan.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
parsevlan() {
8-
local v=${1}:
8+
local v="${1}":
99
set --
1010
while [ -n "$v" ]; do
1111
set -- "$@" "${v%%:*}"

modules.d/40network/net-lib.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ set_ifname() {
243243

244244
# pxelinux provides macaddr '-' separated, but we need ':'
245245
fix_bootif() {
246-
local macaddr=${1}
246+
local macaddr="${1}"
247247
local IFS='-'
248248
# shellcheck disable=SC2086
249249
macaddr=$(printf '%s:' ${macaddr})
@@ -395,11 +395,11 @@ parse_iscsi_root() {
395395
iscsi_target_ip=${v#[[]}
396396
iscsi_target_ip=${iscsi_target_ip%%[]]*}
397397
# shellcheck disable=SC1087
398-
v=${v#[[]$iscsi_target_ip[]]:}
398+
v=${v#[[]"$iscsi_target_ip"[]]:}
399399
;;
400400
*)
401401
iscsi_target_ip=${v%%[:]*}
402-
v=${v#$iscsi_target_ip:}
402+
v=${v#"$iscsi_target_ip":}
403403
;;
404404
esac
405405

@@ -467,7 +467,7 @@ parse_iscsi_root() {
467467
}
468468

469469
ip_to_var() {
470-
local v=${1}:
470+
local v="${1}":
471471
local i
472472
set --
473473
while [ -n "$v" ]; do
@@ -476,7 +476,7 @@ ip_to_var() {
476476
i="${v%%\]:*}"
477477
i="${i##\[}"
478478
set -- "$@" "$i"
479-
v=${v#\[$i\]:}
479+
v=${v#\["$i"\]:}
480480
else
481481
set -- "$@" "${v%%:*}"
482482
v=${v#*:}
@@ -565,7 +565,7 @@ ip_to_var() {
565565
}
566566

567567
route_to_var() {
568-
local v=${1}:
568+
local v="${1}":
569569
local i
570570
set --
571571
while [ -n "$v" ]; do
@@ -574,7 +574,7 @@ route_to_var() {
574574
i="${v%%\]:*}"
575575
i="${i##\[}"
576576
set -- "$@" "$i"
577-
v=${v#\[$i\]:}
577+
v=${v#\["$i"\]:}
578578
else
579579
set -- "$@" "${v%%:*}"
580580
v=${v#*:}
@@ -691,7 +691,7 @@ wait_for_route_ok() {
691691

692692
while [ $cnt -lt $timeout ]; do
693693
li=$(ip route show)
694-
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
694+
[ -n "$li" ] && [ -z "${li##*"$1"*}" ] && return 0
695695
sleep 0.1
696696
cnt=$((cnt + 1))
697697
done

modules.d/45url-lib/module-setup.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install() {
4545
done
4646
if [[ $_found ]] && [[ -n $_crts ]]; then
4747
for _crt in $_crts; do
48-
if ! inst "${_crt#$dracutsysrootdir}"; then
48+
if ! inst "${_crt#"$dracutsysrootdir"}"; then
4949
dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work."
5050
continue
5151
fi
@@ -78,7 +78,7 @@ install() {
7878
# install everything in it
7979
mkdir -p -- "${initdir}/${_p11root}"
8080
if ! $DRACUT_CP -L -t "${initdir}/${_p11root}" "${dracutsysrootdir}${_p11root}"/*; then
81-
dwarn "Couldn't install from p11-kit trust dir '${_p11root#$dracutsysrootdir}'; HTTPS might not work."
81+
dwarn "Couldn't install from p11-kit trust dir '${_p11root#"$dracutsysrootdir"}'; HTTPS might not work."
8282
fi
8383
done
8484
done

modules.d/45url-lib/url-lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ nfs_already_mounted() {
141141
if [ "$path" = "$p" ]; then
142142
echo "$mnt"
143143
elif str_starts "$path" "$p"; then
144-
echo "$mnt"/"${path#$p/}"
144+
echo "$mnt"/"${path#"$p"/}"
145145
fi
146146
fi
147147
done < /proc/mounts

modules.d/50plymouth/plymouth-populate-initrd.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ if [[ $hostonly ]]; then
3434
else
3535
for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/*; do
3636
[[ -f $x ]] || continue
37-
THEME_DIR=$(dirname "${x#$dracutsysrootdir}")
37+
THEME_DIR=$(dirname "${x#"$dracutsysrootdir"}")
3838
# shellcheck disable=SC2174
3939
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
40-
inst_multiple "${x#$dracutsysrootdir}"
40+
inst_multiple "${x#"$dracutsysrootdir"}"
4141
done
4242
(
4343
cd "${initdir}"/usr/share/plymouth/themes || exit

modules.d/90crypt/crypt-lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ ask_for_password() {
141141
# example:
142142
# test_dev -f LABEL="nice label" /some/file1
143143
test_dev() {
144-
local test_op=$1
144+
local test_op="$1"
145145
local dev="$2"
146146
local f="$3"
147147
local ret=1

modules.d/90crypt/parse-crypt.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ else
5353

5454
uuid=${uuid##luks-}
5555
if luksname=$(_cryptgetargsname "$uuid="); then
56-
luksname="${luksname#$uuid=}"
56+
luksname="${luksname#"$uuid"=}"
5757
else
5858
luksname="luks-$uuid"
5959
fi
@@ -93,7 +93,7 @@ else
9393

9494
serialid=${serialid##luks-}
9595
if luksname=$(_cryptgetargsname "$serialid="); then
96-
luksname="${luksname#$serialid=}"
96+
luksname="${luksname#"$serialid"=}"
9797
else
9898
luksname="luks-$serialid"
9999
fi
@@ -133,7 +133,7 @@ else
133133

134134
luksid=${luksid##luks-}
135135
if luksname=$(_cryptgetargsname "$luksid="); then
136-
luksname="${luksname#$luksid=}"
136+
luksname="${luksname#"$luksid"=}"
137137
else
138138
luksname="luks-$luksid"
139139
fi

modules.d/90dm/dm-shutdown.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
_remove_dm() {
4-
local dev=$1
4+
local dev="$1"
55
local s
66
local devname
77

@@ -26,7 +26,7 @@ _remove_dm() {
2626

2727
_do_dm_shutdown() {
2828
local ret=0
29-
local final=$1
29+
local final="$1"
3030
local dev
3131

3232
info "Disassembling device-mapper devices"

modules.d/90dmraid/dmraid.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
2626
# only activate specified DM RAIDS
2727
for r in $DM_RAIDS; do
2828
for s in $SETS; do
29-
if [ "${s##$r}" != "$s" ]; then
29+
if [ "${s##"$r"}" != "$s" ]; then
3030
info "Activating $s"
3131
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
3232
fi

modules.d/90mdraid/md-shutdown.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
_do_md_shutdown() {
44
local ret
5-
local final=$1
5+
local final="$1"
66
info "Waiting for mdraid devices to be clean."
77
mdadm -vv --wait-clean --scan | vinfo
88
ret=$?

modules.d/95lunmask/parse-lunmask.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
44

55
create_udev_rule() {
6-
local transport=$1
7-
local tgtid=$2
8-
local lun=$3
9-
local _rule=/etc/udev/rules.d/51-${transport}-lunmask-${tgtid}.rules
6+
local transport="$1"
7+
local tgtid="$2"
8+
local lun="$3"
9+
local _rule=/etc/udev/rules.d/51-"${transport}"-lunmask-"${tgtid}".rules
1010

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

modules.d/98dracut-systemd/rootfs-generator.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ EOF
4444
}
4545

4646
generator_mount_rootfs() {
47-
local _type=$2
48-
local _flags=$3
47+
local _type="$2"
48+
local _flags="$3"
4949
local _name
5050

5151
[ -z "$1" ] && return 0

modules.d/98syslog/rsyslogd-start.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ if [ -f /var/run/syslogd.pid ]; then
1111
fi
1212

1313
rsyslog_config() {
14-
local server=$1
14+
local server="$1"
1515
shift
16-
local syslog_template=$1
16+
local syslog_template="$1"
1717
shift
18-
local filters=$*
18+
local filters="$*"
1919
local filter=
2020

2121
cat "$syslog_template"

modules.d/98usrmount/mount-usr.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ filtersubvol() {
2020
}
2121

2222
fsck_usr() {
23-
local _dev=$1
24-
local _fs=$2
25-
local _fsopts=$3
23+
local _dev="$1"
24+
local _fs="$2"
25+
local _fsopts="$3"
2626
local _fsckoptions
2727

2828
if [ -f "$NEWROOT"/fsckoptions ]; then

0 commit comments

Comments
 (0)