Make checking if a variable is defined/set work with `set -u`.
[[ "$(type -t "$1")" == "function" ]]
}
-if ! [[ $dracutbasedir ]]; then
+if ! [[ ${dracutbasedir-} ]]; then
dracutbasedir=${BASH_SOURCE[0]%/*}
[[ $dracutbasedir == dracut-functions* ]] && dracutbasedir="."
[[ $dracutbasedir ]] || dracutbasedir="."
dlog_init
fi
-if ! [[ $initdir ]]; then
+if ! [[ ${initdir-} ]]; then
dfatal "initdir not set"
exit 1
fi
mkdir -p "$initdir"
fi
-if ! [[ $kernel ]]; then
+if ! [[ ${kernel-} ]]; then
kernel=$(uname -r)
export kernel
fi
srcmods="$(realpath -e "${dracutsysrootdir-}/lib/modules/$kernel")"
-[[ $drivers_dir ]] && {
+[[ ${drivers_dir-} ]] && {
if ! command -v kmod &> /dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
export srcmods
# export standard hookdirs
-[[ $hookdirs ]] || {
+[[ ${hookdirs-} ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot "
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
hookdirs+="pre-mount pre-pivot cleanup mount "
# shellcheck source=./dracut-functions.sh
. "$dracutbasedir"/dracut-functions.sh
-if ! [[ $DRACUT_INSTALL ]]; then
+if ! [[ "${DRACUT_INSTALL-}" ]]; then
DRACUT_INSTALL=$(find_binary dracut-install)
fi
fi
# Detect lib paths
-if ! [[ $libdirs ]]; then
+if ! [[ ${libdirs-} ]]; then
if [[ $($DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} --dry-run -R "$DRACUT_TESTBIN") == */lib64/* ]] &> /dev/null \
&& [[ -d "${dracutsysrootdir-}/lib64" ]]; then
libdirs+=" /lib64"
local __oldumask
local ret=0
local errmsg=
- [ -z "$stdloglvl" ] && stdloglvl=4
- [ -z "$sysloglvl" ] && sysloglvl=0
- [ -z "$kmsgloglvl" ] && kmsgloglvl=0
+ [ -z "${stdloglvl-}" ] && stdloglvl=4
+ [ -z "${sysloglvl-}" ] && sysloglvl=0
+ [ -z "${kmsgloglvl-}" ] && kmsgloglvl=0
# Skip initialization if it's already done.
- [ -n "$maxloglvl" ] && return 0
+ [ -n "${maxloglvl-}" ] && return 0
- if [ -z "$fileloglvl" ]; then
- [ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
+ if [ -z "${fileloglvl-}" ]; then
+ [ -w "${logfile-}" ] && fileloglvl=4 || fileloglvl=0
elif ((fileloglvl > 0)); then
- if [[ $logfile ]]; then
+ if [[ ${logfile-} ]]; then
__oldumask=$(umask)
umask 0377
! [ -e "$logfile" ] && : > "$logfile"
debug=yes
}
-[[ $dracutbasedir ]] || dracutbasedir="${dracutsysrootdir-}"/usr/lib/dracut
+[[ ${dracutbasedir-} ]] || dracutbasedir="${dracutsysrootdir-}"/usr/lib/dracut
# These config variables needs to be exported for dracut-install.
export add_dlopen_features="" omit_dlopen_features=""
((${#libdirs_l[@]})) && libdirs="${libdirs_l[*]}"
[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
-[[ ! $stdloglvl ]] && stdloglvl=4
+[[ ! ${stdloglvl-} ]] && stdloglvl=4
stdloglvl=$((stdloglvl + verbosity_mod_l))
((stdloglvl > 6)) && stdloglvl=6
((stdloglvl < 0)) && stdloglvl=0
}
setmemdebug() {
- if [ -z "$DEBUG_MEM_LEVEL" ]; then
+ if [ -z "${DEBUG_MEM_LEVEL-}" ]; then
DEBUG_MEM_LEVEL=$(getargnum 0 0 5 rd.memdebug)
export DEBUG_MEM_LEVEL
fi
#!/usr/bin/env bash
set -e
-[ -z "$TEST_FSTYPE" ] && TEST_FSTYPE="ext4"
+[ -z "${TEST_FSTYPE-}" ] && TEST_FSTYPE="ext4"
# shellcheck disable=SC2034
TEST_DESCRIPTION="root filesystem on multiple device $TEST_FSTYPE (on top of RAID and LUKS)"
local test_name="$1"
local mac=$2
local cmdline="$3"
- local fstype=$4
- local fsopt=$5
+ local fstype=${4-ext4}
+ local fsopt=${5-ro}
local found opts nbdinfo
- [[ $fstype ]] || fstype=ext4
- [[ $fsopt ]] || fsopt="ro"
-
echo "CLIENT TEST START: $test_name"
declare -a disk_args=()
# shellcheck disable=SC1090
[[ -e .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} ]] && . .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
-if [[ -z $TESTDIR ]] || [[ ! -d $TESTDIR ]]; then
+if [[ -z ${TESTDIR-} ]] || [[ ! -d $TESTDIR ]]; then
TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX)
fi
echo "TESTDIR=\"$TESTDIR\"" > .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
export TESTDIR
export BOOT_ROOT="$TESTDIR"
-if [[ -z $basedir ]]; then basedir="$(realpath ../..)"; fi
+if [[ -z ${basedir-} ]]; then basedir="$(realpath ../..)"; fi
DRACUT=${DRACUT-dracut}
PKGLIBDIR=${PKGLIBDIR-$basedir}
if [[ -f /etc/machine-id ]]; then
read -r TOKEN < /etc/machine-id || true
fi
-[ -z "$TOKEN" ] && . /etc/os-release && TOKEN="$ID"
+[ -z "${TOKEN-}" ] && . /etc/os-release && TOKEN="$ID"
TEST_KERNEL_CMDLINE+=" root=LABEL=dracut panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot ${DEBUGFAIL-} "
# we are running inside a container already
# shellcheck disable=SC2012
- [[ $KVERSION ]] || KVERSION="$(cd /lib/modules && ls -1 | tail -1)"
+ [[ ${KVERSION-} ]] || KVERSION="$(cd /lib/modules && ls -1 | tail -1)"
# shellcheck disable=SC2012
- [[ $KVERSION ]] || KVERSION="$(cd /usr/lib/modules && ls -1 | tail -1)"
- [[ $KVERSION ]] || KVERSION="$(uname -r)"
+ [[ ${KVERSION-} ]] || KVERSION="$(cd /usr/lib/modules && ls -1 | tail -1)"
+ [[ ${KVERSION-} ]] || KVERSION="$(uname -r)"
}
set_vmlinux_env() {
if ! [ -f "$VMLINUZ" ]; then
[[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id
- if [[ $MACHINE_ID ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
+ if [[ ${MACHINE_ID-} ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
elif [ -f "/boot/vmlinuz-${KVERSION}" ]; then
VMLINUZ="/boot/vmlinuz-${KVERSION}"