]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
use ${var:+val} rather than ${var+val}
authorHarald Hoyer <harald@redhat.com>
Thu, 22 Aug 2013 09:24:01 +0000 (11:24 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 22 Aug 2013 09:24:01 +0000 (11:24 +0200)
${var:+val} also catches var=""

50-dracut.install
dracut-functions.sh
dracut.sh
modules.d/40network/dhclient-script.sh
modules.d/40network/ifup.sh
modules.d/95iscsi/iscsiroot.sh
modules.d/95nbd/nbdroot.sh
modules.d/95nfs/nfs-lib.sh
test/TEST-04-FULL-SYSTEMD/test.sh
test/TEST-50-MULTINIC/test.sh

index a0623a1c380882f404d042deb9afefbe2b399800..02827411f64130bc121b6eae25c68c61b37c1cce 100755 (executable)
@@ -22,7 +22,7 @@ done
 ret=0
 case "$1" in
     add)
-       dracut ${noimageifnotneeded+--noimageifnotneeded} "$3"/initrd "$2"
+       dracut ${noimageifnotneeded:+--noimageifnotneeded} "$3"/initrd "$2"
         ret=$?
        ;;
     remove)
index 8f32f07a85dfc391ec6ec614daef6d22db04dce8..8a1b73fcf1aa70b81e41ebd61dd4a8477caa568c 100755 (executable)
@@ -688,37 +688,37 @@ fi
 [[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
 inst_dir() {
     [[ -e ${initdir}/"$1" ]] && return 0  # already there
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@" || :
 }
 
 inst() {
     [[ -e ${initdir}/"${2:-$1}" ]] && return 0  # already there
         #dinfo "$DRACUT_INSTALL -l $@"
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-H} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-H} "$@" || :
 }
 
 inst_simple() {
     [[ -e ${initdir}/"${2:-$1}" ]] && return 0  # already there
     [[ -e $1 ]] || return 1  # no source
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} "$@" || :
 }
 
 inst_symlink() {
     [[ -e ${initdir}/"${2:-$1}" ]] && return 0  # already there
     [[ -L $1 ]] || return 1
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@" || :
 }
 
 inst_multiple() {
     local ret
         #dinfo "initdir=$initdir $DRACUT_INSTALL -l $@"
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@"
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@"
     ret=$?
-    (($ret != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@" || :
+    (($ret != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@" || :
     return $ret
 }
 
@@ -729,18 +729,18 @@ dracut_install() {
 inst_library() {
     [[ -e ${initdir}/"${2:-$1}" ]] && return 0  # already there
     [[ -e $1 ]] || return 1  # no source
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@" || :
 }
 
 inst_binary() {
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@" || :
 }
 
 inst_script() {
-    $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@"
-    (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l}  ${DRACUT_FIPS_MODE+-H} "$@" || :
+    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@"
+    (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-H} "$@" || :
 }
 
 # find symlinks linked to given library file
@@ -850,13 +850,11 @@ inst_rule_initqueue() {
 inst_rules() {
     local _target=/etc/udev/rules.d _rule _found
 
-    [[ $hostonly ]] || unset hostonly
-
     inst_dir "${udevdir}/rules.d"
     inst_dir "$_target"
     for _rule in "$@"; do
         if [ "${_rule#/}" = "$_rule" ]; then
-            for r in ${udevdir}/rules.d ${hostonly+/etc/udev/rules.d}; do
+            for r in ${udevdir}/rules.d ${hostonly:+/etc/udev/rules.d}; do
                 if [[ -e $r/$_rule ]]; then
                     _found="$r/$_rule"
                     inst_rule_programs "$_found"
@@ -1388,7 +1386,7 @@ dracut_kernel_post() {
     local _pid
 
     if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" ]]; then
-        xargs -r modprobe -a ${_moddirname+-d ${_moddirname}/} \
+        xargs -r modprobe -a ${_moddirname:+-d ${_moddirname}/} \
             --ignore-install --show-depends --set-version $kernel \
             < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" 2>/dev/null \
             | sort -u \
@@ -1399,7 +1397,7 @@ dracut_kernel_post() {
 
         (
             if [[ $DRACUT_INSTALL ]] && [[ -z $_moddirname ]]; then
-                xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
+                xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
             else
                 while read _modpath; do
                     local _destpath=$_modpath
@@ -1418,7 +1416,7 @@ dracut_kernel_post() {
                 for _fwdir in $fw_dir; do
                     echo $_fwdir/$line;
                 done;
-            done | xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -a -o
+            done | xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a -o
         else
             for _fw in $(xargs -r modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"); do
                 for _fwdir in $fw_dir; do
index 0c42958b4ee410f24a55fe141dd0f0439ec07557..7ad9d1eff072fa3907c39b8d71731caa019f4c6b 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -729,7 +729,7 @@ fi
 
 if ! [[ $print_cmdline ]]; then
     inst /bin/sh
-    if ! $DRACUT_INSTALL ${initdir+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
+    if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
         unset DRACUT_RESOLVE_LAZY
         export DRACUT_RESOLVE_DEPS=1
     fi
@@ -1184,7 +1184,7 @@ if [[ $kernel_only != yes ]]; then
         find "$initdir" -type f \
             '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
             -not -path '*.ko' -print0 \
-        | xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} --
+        | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R ${DRACUT_FIPS_MODE:+-H} --
         dinfo "*** Resolving executable dependencies done***"
     fi
 fi
index f04b83dc70dc5c7218c0b9f0a827953157af5da1..07c3d9bec6e70075873b7db01a245644c0afe97c 100755 (executable)
@@ -42,7 +42,7 @@ setup_interface() {
 
     # 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
 }
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
index 32f0ff23d31023d6937a390688ae2ea427405522..f9e16694f8badc426dc1c355c0e9a4b1bff6d574 100755 (executable)
@@ -124,10 +124,10 @@ do_static() {
     [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
     if strstr $ip '*:*:*'; then
         # note no ip addr flush for ipv6
-        ip addr add $ip/$mask ${srv+peer $srv} dev $netif
+        ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
     else
         ip addr flush dev $netif
-        ip addr add $ip/$mask ${srv+peer $srv} brd + dev $netif
+        ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
     fi
 
     [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
index 0c042198597d4ef0754e24c4f814ed6bb354d69c..5181f523b792d8fb157a5a0cae0cb957f7717d3e 100755 (executable)
@@ -96,7 +96,7 @@ handle_netroot()
 # XXX is this needed?
     getarg ro && iscsirw=ro
     getarg rw && iscsirw=rw
-    fsopts=${fsopts+$fsopts,}${iscsirw}
+    fsopts=${fsopts:+$fsopts,}${iscsirw}
 
     if [ -z $iscsi_initiator ]; then
     # XXX Where are these from?
@@ -155,12 +155,12 @@ handle_netroot()
     iscsistart -i $iscsi_initiator -t $iscsi_target_name        \
         -g $iscsi_target_group -a $iscsi_target_ip      \
         -p $iscsi_target_port \
-        ${iscsi_username+-u $iscsi_username} \
-        ${iscsi_password+-w $iscsi_password} \
-        ${iscsi_in_username+-U $iscsi_in_username} \
-        ${iscsi_in_password+-W $iscsi_in_password} \
-       ${iscsi_iface_name+--param iface.iscsi_ifacename=$iscsi_iface_name} \
-       ${iscsi_netdev_name+--param iface.net_ifacename=$iscsi_netdev_name} \
+        ${iscsi_username:+-u $iscsi_username} \
+        ${iscsi_password:+-w $iscsi_password} \
+        ${iscsi_in_username:+-U $iscsi_in_username} \
+        ${iscsi_in_password:+-W $iscsi_in_password} \
+       ${iscsi_iface_name:+--param iface.iscsi_ifacename=$iscsi_iface_name} \
+       ${iscsi_netdev_name:+--param iface.net_ifacename=$iscsi_netdev_name} \
         ${iscsi_param} \
        || :
 
index 1a1ed54577cb06fe74a291d9cb3f6bb76d02f220..823da0ea030bfd88d0e6eeaf6d447863ffdde8fc 100755 (executable)
@@ -76,12 +76,12 @@ while [ -n "$nbdflags" ]; do
         nbdrw=$f
         continue
     fi
-    fsopts=${fsopts+$fsopts,}$f
+    fsopts=${fsopts:+$fsopts,}$f
 done
 
 getarg ro && nbdrw=ro
 getarg rw && nbdrw=rw
-fsopts=${fsopts+$fsopts,}${nbdrw}
+fsopts=${fsopts:+$fsopts,}${nbdrw}
 
 # XXX better way to wait for the device to be made?
 i=0
index 628996ca4a913264a0d9f8c2f4ac644177a68c78..f5fc56d71ef33100ef73e8df9f5ac9b1977592c0 100755 (executable)
@@ -128,7 +128,7 @@ mount_nfs() {
     nfs_to_var $nfsroot $netif
     munge_nfs_options
     if [ "$nfs" = "nfs4" ]; then
-        options=$options${nfslock+,$nfslock}
+        options=$options${nfslock:+,$nfslock}
     else
         # NFSv{2,3} doesn't support using locks as it requires a helper to
         # transfer the rpcbind state to the new root
index d4998d855e95a4f6b4affa24ae567e32d000a4f9..3eeb84068df77f50b4242c51b6a731f45f1104f0 100755 (executable)
@@ -82,7 +82,7 @@ test_setup() {
        inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
        inst_multiple grep
         inst_simple ./fstab /etc/fstab
-        rpm -ql systemd | xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -o -a -l
+        rpm -ql systemd | xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
         inst /lib/systemd/system/systemd-remount-fs.service
         inst /lib/systemd/systemd-remount-fs
         inst /lib/systemd/system/systemd-journal-flush.service
index b616e6b19e5c7ef426cf91407d9147836509b316..7c9d544cf980ab737714d678a5309d0ddcb4ce41 100755 (executable)
@@ -20,7 +20,7 @@ run_server() {
         -display none \
         -net socket,listen=127.0.0.1:12350 \
         -net nic,macaddr=52:54:01:12:34:56,model=e1000 \
-        ${SERIAL+-serial "$SERIAL"} \
+        ${SERIAL:+-serial "$SERIAL"} \
         -watchdog i6300esb -watchdog-action poweroff \
         -kernel /boot/vmlinuz-"$KVERSION" \
         -append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \