]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix: address shellcheck SC2166
authorBenjamin Drung <benjamin.drung@canonical.com>
Thu, 13 Jun 2024 22:16:08 +0000 (00:16 +0200)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Fri, 14 Jun 2024 18:04:02 +0000 (14:04 -0400)
shellcheck complains about SC2166:
> Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.

See https://github.com/koalaman/shellcheck/wiki/SC2166

Address the valid shellcheck complaint instead of ignoring it globally.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
45 files changed:
.shellcheckrc
dracut-initramfs-restore.sh
modules.d/00warpclock/module-setup.sh
modules.d/01fips/fips.sh
modules.d/02caps/caps.sh
modules.d/30convertfs/convertfs.sh
modules.d/35network-legacy/dhclient-script.sh
modules.d/35network-legacy/ifup.sh
modules.d/35network-legacy/module-setup.sh
modules.d/45net-lib/ifname-genrules.sh
modules.d/45net-lib/net-lib.sh
modules.d/50plymouth/plymouth-pretrigger.sh
modules.d/80cms/cmssetup.sh
modules.d/80cms/module-setup.sh
modules.d/81cio_ignore/module-setup.sh
modules.d/90crypt/crypt-lib.sh
modules.d/90crypt/cryptroot-ask.sh
modules.d/90crypt/probe-keydev.sh
modules.d/90dmraid/dmraid.sh
modules.d/90dmsquash-live/apply-live-updates.sh
modules.d/90dmsquash-live/dmsquash-live-root.sh
modules.d/90livenet/livenetroot.sh
modules.d/90multipath/module-setup.sh
modules.d/91zipl/install_zipl_cmdline.sh
modules.d/91zipl/module-setup.sh
modules.d/95cifs/cifs-lib.sh
modules.d/95dasd/module-setup.sh
modules.d/95dasd_mod/module-setup.sh
modules.d/95fcoe/fcoe-edd.sh
modules.d/95fcoe/fcoe-up.sh
modules.d/95fcoe/parse-fcoe.sh
modules.d/95iscsi/module-setup.sh
modules.d/95nbd/nbdroot.sh
modules.d/95resume/resume.sh
modules.d/95rootfs-block/module-setup.sh
modules.d/95rootfs-block/mount-root.sh
modules.d/95virtfs/mount-virtfs.sh
modules.d/95virtiofs/mount-virtiofs.sh
modules.d/95virtiofs/parse-virtiofs.sh
modules.d/95zfcp/module-setup.sh
modules.d/95znet/module-setup.sh
modules.d/98selinux/selinux-loadpolicy.sh
modules.d/99base/dracut-dev-lib.sh
modules.d/99base/dracut-lib.sh
test/TEST-20-NFS/client-init.sh

index 90d03cb9dd382d897a802832d2a65b5e7a608562..26c5c4753c5ba71157e34213fb6b4c1bfbd696e5 100644 (file)
@@ -1,7 +1,3 @@
-# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
-# https://github.com/koalaman/shellcheck/wiki/SC2166
-disable=SC2166
-
 # SC2154: Variable is referenced but not assigned
 # https://github.com/koalaman/shellcheck/wiki/SC2154
 disable=SC2154
index cc561b221af95b82903fc1dfa12fe167c63921fd..4491ad3d88b9b99a1d18b0355bf0a8131294f0c8 100755 (executable)
@@ -83,7 +83,7 @@ if [[ -d squash ]]; then
 fi
 
 if grep -q -w selinux /sys/kernel/security/lsm 2> /dev/null \
-    && [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then
+    && [ -e /etc/selinux/config ] && [ -x /usr/sbin/setfiles ]; then
     . /etc/selinux/config
     if [[ $SELINUX != "disabled" && -n $SELINUXTYPE ]]; then
         /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null
index 44aa17790f1cb68cf915b2e41eb7d24a1b296133..dd093f3c480ffe6e0f4abb5f2cd14f0beb53be14 100755 (executable)
@@ -7,7 +7,7 @@ check() {
 
     # hwclock does not exist on S390(x), bail out silently then
     local _arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1
+    [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] && return 1
 
     # If the binary(s) requirements are not fulfilled the module can't be installed.
     require_binaries hwclock || return 1
index d4045057e7022e6a4a7463a67204d8c11a9f66fd..2c7b2e36a923d05ac1100db9cd75418fd368e1ec 100755 (executable)
@@ -101,7 +101,7 @@ fips_load_crypto() {
                 # check if kernel provides generic algo
                 _found=0
                 while read -r _k _ _v || [ -n "$_k" ]; do
-                    [ "$_k" != "name" -a "$_k" != "driver" ] && continue
+                    [ "$_k" != "name" ] && [ "$_k" != "driver" ] && continue
                     [ "$_v" != "$_module" ] && continue
                     _found=1
                     break
index 6c28299a26ff2c6fdc052667419704e1b4a78147..d0997a147c7b74302d697042fe3f4c28a9c06976 100755 (executable)
@@ -12,12 +12,12 @@ if [ "$capsmode" = "1" ]; then
     info "Loading CAPS_MODULES $CAPS_MODULES"
     for i in $CAPS_MODULES; do modprobe "$i" 2>&1 > /dev/null | vinfo; done
 
-    if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then
+    if [ "$CAPS_MODULES_DISABLED" = "1" ] && [ -e /proc/sys/kernel/modules_disabled ]; then
         info "Disabling module loading."
         echo "$CAPS_MODULES_DISABLED" > /proc/sys/kernel/modules_disabled
     fi
 
-    if [ "$CAPS_KEXEC_DISABLED" = "1" -a -e /proc/sys/kernel/kexec_disabled ]; then
+    if [ "$CAPS_KEXEC_DISABLED" = "1" ] && [ -e /proc/sys/kernel/kexec_disabled ]; then
         info "Disabling kexec."
         echo "$CAPS_KEXEC_DISABLED" > /proc/sys/kernel/kexec_disabled
     fi
index 58fa56df7d43fe77a97fb4a05cbeb898b008d07f..4d2613d7debe604608c4eed9a7c4b8f0ebb2a06a 100755 (executable)
@@ -21,13 +21,13 @@ while [[ $ROOT != "${ROOT%/}" ]]; do
     ROOT=${ROOT%/}
 done
 
-if [ ! -L "$ROOT"/var/run -a -e "$ROOT"/var/run ]; then
+if [ ! -L "$ROOT"/var/run ] && [ -e "$ROOT"/var/run ]; then
     echo "Converting /var/run to symlink"
     mv -f "$ROOT"/var/run "$ROOT"/var/run.runmove~
     ln -sfn ../run "$ROOT"/var/run
 fi
 
-if [ ! -L "$ROOT"/var/lock -a -e "$ROOT"/var/lock ]; then
+if [ ! -L "$ROOT"/var/lock ] && [ -e "$ROOT"/var/lock ]; then
     echo "Converting /var/lock to symlink"
     mv -f "$ROOT"/var/lock "$ROOT"/var/lock.lockmove~
     ln -sfn ../run/lock "$ROOT"/var/lock
index b3e5e7574d7b2f3642fd2ee3d434d7dc5e9c14d9..6cbc9c21c389e715fab991a71ad848b681cb3149 100755 (executable)
@@ -114,7 +114,7 @@ parse_option_121() {
         shift
 
         # Is the destination a multicast group?
-        if [ "$1" -ge 224 -a "$1" -lt 240 ]; then
+        if [ "$1" -ge 224 ] && [ "$1" -lt 240 ]; then
             multicast=1
         else
             multicast=0
@@ -153,7 +153,7 @@ parse_option_121() {
         # Multicast routing on Linux
         #  - If you set a next-hop address for a multicast group, this breaks with Cisco switches
         #  - If you simply leave it link-local and attach it to an interface, it works fine.
-        if [ $multicast -eq 1 -o "$gateway" = "0.0.0.0" ]; then
+        if [ $multicast -eq 1 ] || [ "$gateway" = "0.0.0.0" ]; then
             temp_result="$destination dev $interface"
         else
             temp_result="$destination via $gateway dev $interface"
index 3b54b6c48815bb55a94e7b521ad42eb663516624..9827e2e8ce1868e8f90e3aa20a2882a55d2519c3 100755 (executable)
@@ -301,7 +301,7 @@ if [ -z "$NO_BOND_MASTER" ]; then
                 key=${arg%%=*}
                 value=${arg##*=}
                 # %{value:0:1} is replaced with non-bash specific construct
-                if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then
+                if [ "${key}" = "arp_ip_target" ] && [ "${#value}" != "0" ] && [ "+${value%%+*}" != "+" ]; then
                     OLDIFS=$IFS
                     IFS=','
                     for arp_ip in $value; do
@@ -421,7 +421,7 @@ fi
 
 # disable manual ifup while netroot is set for simplifying our logic
 # in netroot case we prefer netroot to bringup $netif automatically
-[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
+[ -n "$2" ] && [ "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
 
 if [ -n "$manualup" ]; then
     : > "/tmp/net.$netif.manualup"
@@ -536,12 +536,12 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e "/tmp/net.${netif}.up" ]; then
         # No ip lines, no bootdev -> default to dhcp
         ip=$(getarg ip)
 
-        if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
+        if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" ] && [ "$netroot" = "dhcp6" ]; then
             load_ipv6
             do_dhcp -6
             ret=$?
         fi
-        if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
+        if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" ] && [ "$netroot" != "dhcp6" ]; then
             do_dhcp -4
             ret=$?
         fi
index 42257ebe7024aaa19ee93233db9ff15c3c13d6e3..00e1f36b950c2a30ed044b8bff63d99d78eff559 100755 (executable)
@@ -71,7 +71,7 @@ install() {
         (
             # shellcheck disable=SC1090
             . "$i"
-            if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \
+            if ! [ "${ONBOOT}" = "no" ] || [ "${ONBOOT}" = "NO" ] \
                 && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
                 if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then
                     mkdir -p "$initdir"/etc/teamd
index b9b95c4877ca95d4b20225d2c75c76fa402d70b6..34b7a2eb83e7d5e95f2c704bcbc7b1a699952a77 100755 (executable)
@@ -17,7 +17,7 @@ command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
         if [ -f /tmp/ifname-"$ifname_if" ]; then
             read -r oldmac < /tmp/ifname-"$ifname_if"
         fi
-        if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then
+        if [ -n "$oldif" ] && [ -n "$oldmac" ] && [ "$oldif" = "$ifname_if" ] && [ "$oldmac" = "$ifname_mac" ]; then
             # skip same ifname= declaration
             continue
         fi
index 9d88e0d340ac336700a4134bc0c967025829ee1f..dc6be8812db89145afd98335dd94c0d998c737e8 100755 (executable)
@@ -319,7 +319,7 @@ ibft_to_cmdline() {
                         gw="[${gw}]"
                     fi
                 fi
-                if [ -n "$ip" ] && [ -n "$mask" -o -n "$prefix" ]; then
+                if [ -n "$ip" ] && [ -n "$mask" ] || [ -n "$prefix" ]; then
                     echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}"
                 else
                     warn "${iface} does not contain a valid iBFT configuration"
@@ -517,7 +517,7 @@ ip_to_var() {
         return 0
     fi
 
-    if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then
+    if [ "$2" = "dhcp" ] || [ "$2" = "on" ] || [ "$2" = "any" ] || [ "$2" = "dhcp6" ] || [ "$2" = "auto6" ] || [ "$2" = "either6" ]; then
         # format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
         [ -n "$1" ] && dev="$1"
         [ -n "$2" ] && autoconf="$2"
@@ -546,16 +546,16 @@ ip_to_var() {
             ;;
         [0-9]*)
             mtu="$8"
-            if [ -n "${9}" -a -z "${10}" ]; then
+            if [ -n "${9}" ] && [ -z "${10}" ]; then
                 macaddr="${9}"
-            elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
+            elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then
                 macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
             fi
             ;;
         *)
-            if [ -n "${9}" -a -z "${10}" ]; then
+            if [ -n "${9}" ] && [ -z "${10}" ]; then
                 macaddr="${9}"
-            elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
+            elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then
                 macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
             fi
             ;;
index 3d1199902525a133811e36982b4ed6388f5c56ee..a04c79140a8ba9dfaf96c1613c41ce8d5e7a4392 100755 (executable)
@@ -18,10 +18,10 @@ if type plymouthd > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
         mkdir -m 0755 /run/plymouth
         read -r consoledev rest < /sys/class/tty/console/active
         consoledev=${consoledev:-tty0}
-        [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
+        [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
         plymouthd --attach-to-session --pid-file /run/plymouth/pid
         plymouth --show-splash 2>&1 | vinfo
         # reset tty after plymouth messed with it
-        [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
+        [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
     fi
 fi
index 5e5b926718efbbd0e15842af5bd5ed9168e53530..8050f2b409bc752387287fe1d75154326462e0f3 100755 (executable)
@@ -158,7 +158,7 @@ processcmsfile() {
 [[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=")
 
 # Parse configuration
-if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then
+if [ -n "$CMSDASD" ] && [ -n "$CMSCONFFILE" ]; then
     if readcmsfile "$CMSDASD" "$CMSCONFFILE"; then
         ln -s /run/initramfs/"$CMSCONFFILE" /tmp/"$CMSCONFFILE"
         ln -s /run/initramfs/"$CMSCONFFILE" /tmp/cms.conf
index 5b33cd1806111dbb8f4b8a56eab43146ea8ca687..920f0a035936353c5319a4ba414264c9853595a8 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 check() {
     arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
+    [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1
     require_binaries chzdev lszdev || return 1
     return 255
 }
@@ -11,7 +11,7 @@ check() {
 # called by dracut
 depends() {
     arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
+    [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1
     echo znet bash
     return 0
 }
index a54fcb9bda55b47a55d6d8cf896d5c36f8cd2154..6c618fb3cbc7ca05508a9e6234cc9d9e0048b542 100755 (executable)
@@ -6,7 +6,7 @@
 check() {
     # do not add this module by default
     local arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
+    [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1
     return 0
 }
 
@@ -15,7 +15,7 @@ cmdline() {
 
     if [ -e /boot/zipl/active_devices.txt ]; then
         while read -r dev _; do
-            [ "$dev" = "#" -o "$dev" = "" ] && continue
+            [ "$dev" = "#" ] || [ "$dev" = "" ] && continue
             if [ -z "$cio_accept" ]; then
                 cio_accept="$dev"
             else
index f3ba20dcc79d7b7462cce7a6bc01d6acbb74ce6a..766982821625c656cee98cb2df507252fe012d85 100755 (executable)
@@ -148,7 +148,7 @@ test_dev() {
     local mount_point
 
     mount_point=$(mkuniqdir /mnt testdev)
-    [ -n "$dev" -a -n "$*" ] || return 1
+    [ -n "$dev" ] && [ -n "$*" ] || return 1
     [ -d "$mount_point" ] || die 'Mount point does not exist!'
 
     if mount -r "$dev" "$mount_point" > /dev/null 2>&1; then
@@ -175,7 +175,7 @@ test_dev() {
 #   match_dev UUID=123 /dev/dm-1
 # Returns true if /dev/dm-1 UUID starts with "123".
 match_dev() {
-    [ -z "$1" -o "$1" = '*' ] && return 0
+    [ -z "$1" ] || [ "$1" = '*' ] && return 0
     local devlist
     local dev
 
@@ -206,7 +206,7 @@ getkey() {
     local key_dev
     local key_path
 
-    [ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!'
+    [ -z "$keys_file" ] || [ -z "$for_dev" ] && die 'getkey: wrong usage!'
     [ -f "$keys_file" ] || return 1
 
     while IFS=: read -r luks_dev key_dev key_path _ || [ -n "$luks_dev" ]; do
index b1f8df81febe2988c85f7e761fa7d19422877105..ad96a972a07b5c701d191276a1294e3b5f201759 100755 (executable)
@@ -30,7 +30,7 @@ numtries=${4:-10}
 if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; then
     while read -r name dev luksfile luksoptions || [ -n "$name" ]; do
         # ignore blank lines and comments
-        if [ -z "$name" -o "${name#\#}" != "$name" ]; then
+        if [ -z "$name" ] || [ "${name#\#}" != "$name" ]; then
             continue
         fi
 
@@ -137,7 +137,7 @@ unset allowdiscards
 # fallback to passphrase
 ask_passphrase=1
 
-if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then
+if [ -n "$luksfile" ] && [ "$luksfile" != "none" ] && [ -e "$luksfile" ]; then
     # shellcheck disable=SC2086
     if readkey "$luksfile" / "$device" \
         | cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname"; then
@@ -187,7 +187,7 @@ if [ $ask_passphrase -ne 0 ]; then
     unset _timeout
 fi
 
-if [ "$is_keysource" -ne 0 -a "${luksname##luks-}" != "$luksname" ]; then
+if [ "$is_keysource" -ne 0 ] && [ "${luksname##luks-}" != "$luksname" ]; then
     luks_close="$(command -v cryptsetup) close"
     {
         printf -- '[ -e /dev/mapper/%s ] && ' "$luksname"
index e5a3f368a712ebf6ebf39aded1ad56d5c51453fd..bb86b8fa6b8415a4cef82f8108448f1498a77469 100755 (executable)
@@ -6,7 +6,7 @@ real_keydev="$1"
 keypath="$2"
 luksdev="$3"
 
-[ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!'
+[ -z "$real_keydev" ] || [ -z "$keypath" ] && die 'probe-keydev: wrong usage!'
 [ -z "$luksdev" ] && luksdev='*'
 
 info "Probing $real_keydev for $keypath..."
index b517320a367e34b15c9e8d8065e16bffaa932850..c12d92e389910db6fd06309885f7af4c27ae00ae 100755 (executable)
@@ -15,7 +15,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
     info "Scanning for dmraid devices $DM_RAIDS"
     SETS=$(dmraid -c -s)
 
-    if [ "$SETS" = "no raid disks" -o "$SETS" = "no raid sets" ]; then
+    if [ "$SETS" = "no raid disks" ] || [ "$SETS" = "no raid sets" ]; then
         return
     fi
 
index a5a5a391816cc48f87315e21b8f58f08b4ea1ae3..be3b2c20ce3c2de2f39722817435141d634ad4f0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then
+if [ -h /dev/root ] && [ -d /run/initramfs/live/updates ] || [ -d /updates ]; then
     info "Applying updates to live image..."
     mount -o bind /run "$NEWROOT"/run
     # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories
@@ -16,7 +16,7 @@ if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then
 fi
 # release resources on iso-scan boots with rd.live.ram
 if [ -d /run/initramfs/isoscan ] \
-    && [ -f /run/initramfs/squashed.img -o -f /run/initramfs/rootfs.img ]; then
+    && [ -f /run/initramfs/squashed.img ] || [ -f /run/initramfs/rootfs.img ]; then
     umount --detach-loop /run/initramfs/live
     umount /run/initramfs/isoscan
 fi
index 4518852bddd64553243f534bc34ededab98275da..db9383762e73467707c10f53388cf7984ffccb67 100755 (executable)
@@ -67,7 +67,7 @@ if [ ! -f "$livedev" ]; then
     check_dev=$(get_check_dev "$livedev")
     # CD/DVD media check
     [ -b "$check_dev" ] && fs=$(det_fs "$check_dev")
-    if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
+    if [ "$fs" = "iso9660" ] || [ "$fs" = "udf" ]; then
         check="yes"
     fi
     getarg rd.live.check -d check || check=""
@@ -148,7 +148,7 @@ do_live_overlay() {
         pathspec=${overlay##*:}
     fi
 
-    if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then
+    if [ -z "$pathspec" ] || [ "$pathspec" = "auto" ]; then
         pathspec="/${live_dir}/overlay-$l-$u"
     elif ! str_starts "$pathspec" "/"; then
         pathspec=/"${pathspec}"
@@ -156,7 +156,7 @@ do_live_overlay() {
     devspec=${overlay%%:*}
 
     # need to know where to look for the overlay
-    if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
+    if [ -z "$setup" ] && [ -n "$devspec" ] && [ -n "$pathspec" ] && [ -n "$overlay" ]; then
         mkdir -m 0755 -p /run/initramfs/overlayfs
         if ismounted "$devspec"; then
             devmnt=$(findmnt -e -v -n -o 'TARGET' --source "$devspec")
@@ -166,7 +166,7 @@ do_live_overlay() {
         else
             mount -n -t auto "$devspec" /run/initramfs/overlayfs || :
         fi
-        if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then
+        if [ -f /run/initramfs/overlayfs$pathspec ] && [ -w /run/initramfs/overlayfs$pathspec ]; then
             OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} /run/initramfs/overlayfs$pathspec)
             over=$OVERLAY_LOOPDEV
             umount -l /run/initramfs/overlayfs || :
@@ -218,10 +218,10 @@ do_live_overlay() {
         fi
     fi
 
-    if [ -z "$setup" -o -n "$readonly_overlay" ]; then
+    if [ -z "$setup" ] || [ -n "$readonly_overlay" ]; then
         if [ -n "$setup" ]; then
             warn "Using temporary overlay."
-        elif [ -n "$devspec" -a -n "$pathspec" ]; then
+        elif [ -n "$devspec" ] && [ -n "$pathspec" ]; then
             [ -z "$m" ] \
                 && m='   Unable to find a persistent overlay; using a temporary one.'
             m="$m"'
@@ -265,7 +265,7 @@ do_live_overlay() {
             fi
         else
             dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((overlay_size * 1024)) 2> /dev/null
-            if [ -n "$setup" -a -n "$readonly_overlay" ]; then
+            if [ -n "$setup" ] && [ -n "$readonly_overlay" ]; then
                 RO_OVERLAY_LOOPDEV=$(losetup -f --show /overlay)
                 over=$RO_OVERLAY_LOOPDEV
             else
@@ -384,9 +384,9 @@ if [ -n "$FSIMG" ]; then
     fi
     # For writable DM images...
     readonly_base=1
-    if [ -z "$SQUASHED" -a -n "$live_ram" -a -z "$overlayfs" ] \
+    if [ -z "$SQUASHED" ] && [ -n "$live_ram" ] && [ -z "$overlayfs" ] \
         || [ -n "$writable_fsimg" ] \
-        || [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then
+        || [ "$overlay" = none ] || [ "$overlay" = None ] || [ "$overlay" = NONE ]; then
         if [ -z "$readonly_overlay" ]; then
             unset readonly_base
             setup=rw
index 34f91ff1d3739b889630354fbb648df9829a9c53..eccaaed7293f1a5e3785906d3db64e6f2a68a137 100755 (executable)
@@ -47,7 +47,7 @@ while [ "$i" -le "$RETRIES" ]; do
         imgfile=
     fi
 
-    if [ -n "$imgfile" -a -s "$imgfile" ]; then
+    if [ -n "$imgfile" ] && [ -s "$imgfile" ]; then
         break
     else
         if [ $i -ge "$RETRIES" ]; then
index 782a880e3fad560c5e0dafa1f0217d9c7b929833..5ba534fe3419851ab2dce1d507be181d2a8d7777 100755 (executable)
@@ -53,7 +53,7 @@ installkernel() {
     local _arch=${DRACUT_ARCH:-$(uname -m)}
     local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
 
-    if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then
+    if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then
         _s390drivers="=drivers/s390/scsi"
     fi
 
index 9332d31431d8884b891e739ee3c8e0c2fc00958b..3a5133277f4686a728c248aec1e6f35a5631fad4 100755 (executable)
@@ -23,7 +23,7 @@ fi
 
 if [ -f ${MNT}/active_devices.txt ]; then
     while read -r dev _ || [[ $dev ]]; do
-        [ "$dev" = "#" -o "$dev" = "" ] && continue
+        [ "$dev" = "#" ] || [ "$dev" = "" ] && continue
         cio_ignore -r "$dev"
     done < ${MNT}/active_devices.txt
 fi
index cb21454f238bdbfcad0675ab83d22a2710f10ca1..309350e44c25e859eb2051286a5d19cd5657fc5a 100755 (executable)
@@ -12,7 +12,7 @@ get_boot_zipl_dev() {
 check() {
     local _arch=${DRACUT_ARCH:-$(uname -m)}
     # Only for systems on s390 using indirect booting via userland grub
-    [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
+    [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1
     # /boot/zipl contains a first stage kernel used to launch grub in initrd
     [ -d /boot/zipl ] || return 1
     return 0
index b996b41b6575e141ea1c5adeb11d7a93a2c78b5e..9564534a35a75335f340016bcec9a2f4e59caecf 100755 (executable)
@@ -30,7 +30,7 @@ cifs_to_var() {
     # shellcheck disable=SC2034
     server=${server%/*}
 
-    if [ ! "$cifsuser" -o ! "$cifspass" ]; then
+    if [ ! "$cifsuser" ] || [ ! "$cifspass" ]; then
         die "For CIFS support you need to specify a cifsuser and cifspass either in the cifsuser and cifspass commandline parameters or in the root= CIFS URL."
     fi
     # shellcheck disable=SC2034
index 825f95d8106460e076ed2aacefb90826ad499d28..c89d09eb8783111528e6e24873ce13d5000d6781 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 check() {
     local _arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
+    [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1
     require_binaries dasdconf.sh || return 1
     return 0
 }
index 155eaacc712ff51bb74eae88c657e7c52ca4fc53..877068304f7e6f9d9c6f0941572eae38c4673a79 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 check() {
     local _arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
+    [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1
 
     return 0
 }
index 17f8a7c1429dd63c99cc7bb7ad68ab640d229ad5..ece31ba0da23562fa4bf3837af48f3a5ec8685a8 100755 (executable)
@@ -34,7 +34,7 @@ for disk in /sys/firmware/edd/int13_*; do
     fi
     for nic in "${disk}"/pci_dev/net/*; do
         [ -d "$nic" ] || continue
-        if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then
+        if [ -n "${dev_port}" ] && [ -e "${nic}/dev_port" ]; then
             if [ "$(cat "${nic}"/dev_port)" -ne "${dev_port}" ]; then
                 continue
             fi
index 0828f03f5462e52a33bb814732672fffae8fa38c..3c6654c50ab161c4ce64f183d4256ec54c36c421 100755 (executable)
@@ -11,7 +11,7 @@ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
 type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
 
 # Huh? Missing arguments ??
-[ -z "$1" -o -z "$2" ] && exit 1
+[ -z "$1" ] || [ -z "$2" ] && exit 1
 
 netif=$1
 dcb=$2
index a6f284bb7650c51474ed59920ed9e683f10413df..dc4ca320ac95a49dee81506e36d6741b20ef9658 100755 (executable)
@@ -72,7 +72,7 @@ parse_fcoe_opts() {
             ;;
     esac
 
-    if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ]; then
+    if [ "$fcoe_dcb" != "nodcb" ] && [ "$fcoe_dcb" != "dcb" ]; then
         warn "Invalid FCoE DCB option: $fcoe_dcb"
     fi
 
@@ -81,7 +81,7 @@ parse_fcoe_opts() {
         return 0
     fi
 
-    if [ -z "$fcoe_interface" -a -z "$fcoe_mac" ]; then
+    if [ -z "$fcoe_interface" ] && [ -z "$fcoe_mac" ]; then
         warn "fcoe: Neither interface nor MAC specified for fcoe=$fcoe"
         return 1
     fi
index 5eaab4e4f595c11db837cc57b68acf80b74f4d10..bec6e8f4dd90696f56ec5e32fa5a9cc09ced3def 100755 (executable)
@@ -109,11 +109,11 @@ install_iscsiroot() {
     [ -z "$iscsi_address" ] && return
     ip_params_for_remote_addr "$iscsi_address"
 
-    if [ -n "$iscsi_address" -a -n "$iscsi_targetname" ]; then
-        if [ -n "$iscsi_port" -a "$iscsi_port" -eq 3260 ]; then
+    if [ -n "$iscsi_address" ] && [ -n "$iscsi_targetname" ]; then
+        if [ -n "$iscsi_port" ] && [ "$iscsi_port" -eq 3260 ]; then
             iscsi_port=
         fi
-        if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ]; then
+        if [ -n "$iscsi_lun" ] && [ "$iscsi_lun" -eq 0 ]; then
             iscsi_lun=
         fi
         # In IPv6 case rd.iscsi.initatior= must pass address in [] brackets
@@ -163,7 +163,7 @@ installkernel() {
     instmods bnx2i qla4xxx cxgb3i cxgb4i be2iscsi qedi
     hostonly="" instmods iscsi_tcp iscsi_ibft crc32c iscsi_boot_sysfs 8021q
 
-    if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then
+    if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then
         _s390drivers="=drivers/s390/scsi"
     fi
 
index b1a80308a528d22b668e3ade7fb51cd7bd837025..35e24fabefdd5d54939e74a4c4542223256ff396 100755 (executable)
@@ -60,7 +60,7 @@ while [ -n "$nbdopts" ]; do
     if [ -z "$f" ]; then
         break
     fi
-    if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then
+    if [ -z "${f%bs=*}" ] || [ -z "${f%timeout=*}" ]; then
         preopts="$preopts $f"
         continue
     fi
@@ -75,7 +75,7 @@ while [ -n "$nbdflags" ]; do
     if [ -z "$f" ]; then
         break
     fi
-    if [ "$f" = "ro" -o "$f" = "rw" ]; then
+    if [ "$f" = "ro" ] || [ "$f" = "rw" ]; then
         nbdrw=$f
         continue
     fi
@@ -96,7 +96,7 @@ done
 
 # If we didn't get a root= on the command line, then we need to
 # add the udev rules for mounting the nbd0 device
-if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then
+if [ "$root" = "block:/dev/root" ] || [ "$root" = "dhcp" ]; then
     printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' > /etc/udev/rules.d/99-nbd-root.rules
     udevadm control --reload
     wait_for_dev -n /dev/root
index c808880b03e9e584feae8a2eeab22aff0d7ed883..a39b064fa71e0cdc10510ca70f2ce359a1531520 100755 (executable)
@@ -2,7 +2,7 @@
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
-[ -s /.resume -a -b "$resume" ] && {
+[ -s /.resume ] && [ -b "$resume" ] && {
     # First try user level resume; it offers splash etc
     case "$splash" in
         quiet)
index 396fb11e8d002bd7a6be91f8d3c0861bc82234fb..943db48a08d7d0a6886aeb50377bbc798cc38823 100755 (executable)
@@ -40,7 +40,7 @@ cmdline_rootfs() {
         return
     fi
 
-    if [ -n "$_block" -a -b "$_dev" ]; then
+    if [ -n "$_block" ] && [ -b "$_dev" ]; then
         printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")"
     fi
     _fstype="$(find_mp_fstype /)"
index 973069b651a4860ef798b870469b9c91910d4957..5bb6f0fa5a7a0bbd65bb7ada72bc04d18e4c54c9 100755 (executable)
@@ -98,7 +98,7 @@ mount_root() {
     # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
 
     if ! getargbool 0 ro && fsck_able "$rootfs" \
-        && [ "$rootfsck" != "0" -a -z "$fastboot" ] \
+        && [ "$rootfsck" != "0" ] && [ -z "$fastboot" ] \
         && ! strstr "${rflags}" _netdev \
         && ! getargbool 0 rd.skipfsck; then
         umount "$NEWROOT"
@@ -121,6 +121,6 @@ mount_root() {
     fi
 }
 
-if [ -n "$root" -a -z "${root%%block:*}" ]; then
+if [ -n "$root" ] && [ -z "${root%%block:*}" ]; then
     mount_root
 fi
index e52c752da88432979386dcc5e9ea59d99b56e24b..417ace779e4cce300f364faff0a76f961a5d9af8 100755 (executable)
@@ -68,7 +68,7 @@ mount_root() {
     [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null
 }
 
-if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then
+if [ -n "$root" ] && [ -z "${root%%virtfs:*}" ]; then
     mount_root
 fi
 :
index 3d7388456a1cef8a0c527f12659cfdcb040f4de9..3f499cdc8bf53b899bd3a7228308c3519f8f818b 100755 (executable)
@@ -2,7 +2,7 @@
 
 type ismounted > /dev/null 2>&1 || . /lib/dracut-lib.sh
 
-if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then
+if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then
     if ! load_fstype virtiofs; then
         die "virtiofs is required but not available."
     fi
index 760e41385b84d15bde824e96bb7c583ff5a5c49e..192a9509354ce2604f8732c8123d5a2a92f95860 100755 (executable)
@@ -3,7 +3,7 @@
 #      rootfstype=virtiofs root=<tag>
 #      root=virtiofs:<tag>
 
-if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then
+if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then
     # shellcheck disable=SC2034
     rootok=1
 fi
index b547f9bc14a03c9e667e11dbb9512bb8ac5704a6..09a64207dc9df10bd4f6335b6bcad424e6d41e78 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 check() {
     arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
+    [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1
 
     require_binaries zfcp_cio_free sed || return 1
 
index 95164bba64f07d13db2269c4f5e538b02876da6c..c2f5ab9ccf760b24f45282479da52af0fafc7102 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 check() {
     arch=${DRACUT_ARCH:-$(uname -m)}
-    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
+    [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1
 
     require_binaries grep sed seq readlink chzdev || return 1
 
index 0235b8ed45ea9668d561131a8a767097e69ac09e..4e00859b42ba72654053cc0a50c7dc1eb8d9b403 100755 (executable)
@@ -18,7 +18,7 @@ rd_load_policy() {
     fi
 
     # Attempt to load SELinux Policy
-    if [ -x "$NEWROOT/usr/sbin/load_policy" -o -x "$NEWROOT/sbin/load_policy" ]; then
+    if [ -x "$NEWROOT/usr/sbin/load_policy" ] || [ -x "$NEWROOT/sbin/load_policy" ]; then
         local ret=0
         local out
         info "Loading SELinux policy"
@@ -41,7 +41,7 @@ rd_load_policy() {
             return 0
         fi
 
-        if [ $ret -eq 0 -o $ret -eq 2 ]; then
+        if [ $ret -eq 0 ] || [ $ret -eq 2 ]; then
             # If machine requires a relabel, force to permissive mode
             [ -e "$NEWROOT"/.autorelabel ] && LANG=C /usr/sbin/setenforce 0
             mount --rbind /dev "$NEWROOT/dev"
@@ -51,14 +51,14 @@ rd_load_policy() {
         fi
 
         warn "Initial SELinux policy load failed."
-        if [ $ret -eq 3 -o $permissive -eq 0 ]; then
+        if [ $ret -eq 3 ] || [ $permissive -eq 0 ]; then
             warn "Machine in enforcing mode."
             warn "Not continuing"
             emergency_shell -n selinux
             exit 1
         fi
         return 0
-    elif [ $permissive -eq 0 -a "$SELINUX" != "disabled" ]; then
+    elif [ $permissive -eq 0 ] && [ "$SELINUX" != "disabled" ]; then
         warn "Machine in enforcing mode and cannot execute load_policy."
         warn "To disable selinux, add selinux=0 to the kernel command line."
         warn "Not continuing"
index 5779508711b44b1449f0fae019a792034fb6d7f8..6a443a61c5be16de6e58a95a62421359aacef0f7 100755 (executable)
@@ -30,7 +30,7 @@ dev_unit_name() {
         return $?
     fi
 
-    if [ "$dev" = "/" -o -z "$dev" ]; then
+    if [ "$dev" = "/" ] || [ -z "$dev" ]; then
         printf -- "-"
         return 0
     fi
index e83ee94fc435e11ad2c003c49a949137268183c6..efd079cda82bcf4eb08e67b2846bccb5c0d191fc 100755 (executable)
@@ -37,7 +37,7 @@ strstr() {
 # matches; as it would match anything, it's not an interesting case.
 strglob() {
     # shellcheck disable=SC2295
-    [ -n "$1" -a -z "${1##$2}" ]
+    [ -n "$1" ] && [ -z "${1##$2}" ]
 }
 
 # returns OK if $1 contains (anywhere) a match of glob pattern $2
@@ -45,7 +45,7 @@ strglob() {
 # matches; as it would match anything, it's not an interesting case.
 strglobin() {
     # shellcheck disable=SC2295
-    [ -n "$1" -a -z "${1##*$2*}" ]
+    [ -n "$1" ] && [ -z "${1##*$2*}" ]
 }
 
 # returns OK if $1 contains literal string $2 at the beginning, and isn't empty
@@ -354,14 +354,14 @@ splitsep() {
     shift 2
     local tmp
 
-    while [ -n "$str" -a "$#" -gt 1 ]; do
+    while [ -n "$str" ] && [ "$#" -gt 1 ]; do
         tmp="${str%%"$sep"*}"
         eval "$1='${tmp}'"
         str="${str#"$tmp"}"
         str="${str#"$sep"}"
         shift
     done
-    [ -n "$str" -a -n "$1" ] && eval "$1='$str'"
+    [ -n "$str" ] && [ -n "$1" ] && eval "$1='$str'"
     debug_on
     return 0
 }
index 04fb6a7b6aa2fc883ecaa440376ab824cbd6bb73..71ec43726181e145d8528ac59ec7d26f27d0eca1 100755 (executable)
@@ -19,7 +19,7 @@ fi
 echo "made it to the rootfs! Powering down."
 
 while read -r dev _ fstype opts rest || [ -n "$dev" ]; do
-    [ "$fstype" != "nfs" -a "$fstype" != "nfs4" ] && continue
+    [ "$fstype" != "nfs" ] && [ "$fstype" != "nfs4" ] && continue
     echo "nfs-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none
     break
 done < /proc/mounts
@@ -31,7 +31,7 @@ if grep -qF 'rd.live.overlay' /proc/cmdline; then
     fi
 fi
 
-if [ "$fstype" = "nfs" -o "$fstype" = "nfs4" ]; then
+if [ "$fstype" = "nfs" ] || [ "$fstype" = "nfs4" ]; then
 
     serverip=${dev%:*}
     path=${dev#*:}