]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Replace echo -n with printf in code with a /bin/sh shebang
authorMike Gilbert <floppym@gentoo.org>
Wed, 15 Jul 2015 02:22:14 +0000 (22:22 -0400)
committerMike Gilbert <floppym@gentoo.org>
Wed, 15 Jul 2015 02:22:14 +0000 (22:22 -0400)
POSIX does not mandate that echo support the -n parameter.
printf has more well-defined behavior.

18 files changed:
modules.d/04watchdog/watchdog-stop.sh
modules.d/40network/net-lib.sh
modules.d/45ifcfg/write-ifcfg.sh
modules.d/90lvm/lvm_scan.sh
modules.d/95fcoe/fcoe-up.sh
modules.d/98usrmount/mount-usr.sh
modules.d/99base/dracut-lib.sh
modules.d/99base/init.sh
test/TEST-10-RAID/create-root.sh
test/TEST-10-RAID/cryptroot-ask.sh
test/TEST-12-RAID-DEG/create-root.sh
test/TEST-12-RAID-DEG/cryptroot-ask.sh
test/TEST-13-ENC-RAID-LVM/create-root.sh
test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
test/TEST-14-IMSM/cryptroot-ask.sh
test/TEST-20-NFS/client-init.sh
test/TEST-40-NBD/create-root.sh
test/TEST-40-NBD/cryptroot-ask.sh

index 91d45d63ac832f0cf200b3283e90be331fee51cc..921f96954c18490495fc13f7f0e930f594f4ccc3 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
+[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
index a09cdafb6bee9a2363a8f92c17692d42e08f6d3d..6c739e8ea8950d36d3a3687b63fac7d4bf0f7605 100755 (executable)
@@ -189,7 +189,7 @@ set_ifname() {
 fix_bootif() {
     local macaddr=${1}
     local IFS='-'
-    macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
+    macaddr=$(printf '%s:' ${macaddr})
     macaddr=${macaddr%:}
     # strip hardware type field from pxelinux
     [ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
index fa7db2730b75d981503926b443e0125b0b2ed981..251d684d48c553022aced81c555fee198087740d 100755 (executable)
@@ -48,7 +48,7 @@ print_s390() {
         for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
             [ -e $i ] || continue
             channel=$(readlink -f $i)
-            echo -n "${channel##*/},"
+            printf '%s' "${channel##*/},"
         done
     })
     [ -n "$SUBCHANNELS" ] || return 1
index 749564408c0b7d36191f557450ca364df45d55a9..ead28aa4954abb23330ad08d4568f2bf5bbad4c8 100755 (executable)
@@ -15,14 +15,14 @@ SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
 lvmdevs=$(
     for f in /tmp/.lvm_scan-*; do
         [ -e "$f" ] || continue
-        echo -n "${f##/tmp/.lvm_scan-} "
+        printf '%s' "${f##/tmp/.lvm_scan-} "
     done
 )
 
 if [ ! -e /etc/lvm/lvm.conf ]; then
     {
         echo 'devices {';
-        echo -n '    filter = [ '
+        printf '    filter = [ '
         for dev in $lvmdevs; do
             printf '"a|^/dev/%s$|", ' $dev;
         done;
index 43a0ad50c3f89c1ae8474fe0d816624b00edad2b..950e4b6685fd54f1bdeeb65f2cdb84c8e7b1ba38 100755 (executable)
@@ -64,7 +64,7 @@ elif [ "$netdriver" = "bnx2x" ]; then
     sleep 3
     fipvlan "$netif" -c -s
 else
-    echo -n "$netif" > /sys/module/fcoe/parameters/create
+    printf '%s' "$netif" > /sys/module/fcoe/parameters/create
 fi
 
 need_shutdown
index c29610f05c4c164c80245d5a812fd52346a704dc..d1a629c6b9874f6e6b25e49b64b96f496c57b15f 100755 (executable)
@@ -12,7 +12,7 @@ filtersubvol() {
     while [ $# -gt 0 ]; do
         case $1 in
             subvol\=*) :;;
-            *) echo -n "${1}," ;;
+            *) printf '%s' "${1}," ;;
         esac
         shift
     done
index cd1f49f187f222e0349c0e5d2af000e5c76001b8..5ec7b234702a375400aa64040a68ef4568aaaa32 100755 (executable)
@@ -298,7 +298,7 @@ _dogetargs() {
         fi
     done
     if [ -n "$_found" ]; then
-        [ $# -gt 0 ] && echo -n "$@"
+        [ $# -gt 0 ] && printf '%s' "$*"
         return 0
     fi
     return 1;
@@ -329,9 +329,9 @@ getargs() {
     done
     if [ -n "$_gfound" ]; then
         if [ $# -gt 0 ]; then
-            echo -n "$@"
+            printf '%s' "$*"
         else
-            echo -n 1
+            printf 1
         fi
         debug_on
         return 0
index f96dbb5061f1244663c8133704164a6ca886a432..a59e8eac2c9927e6d5b2b1b123ab06dc2b106a71 100755 (executable)
@@ -253,7 +253,7 @@ while :; do
 done
 
 {
-    echo -n "Mounted root filesystem "
+    printf "Mounted root filesystem "
     while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
 } | vinfo
 
index a7e56a510c1b3ea22b8675b92891ad8abf4258c5..7b5f2a764ccab0fec5f99f77eeaa1443b9a7c366 100755 (executable)
@@ -18,7 +18,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /d
 # randomly.
 mdadm -W /dev/md0
 set -e
-echo -n test >keyfile
+printf test >keyfile
 cryptsetup -q luksFormat /dev/md0 /keyfile
 echo "The passphrase is test"
 cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
index 407d0677a97db46dcbceffc8a08d2f39baebf4d1..c39eff6e91d1880925dde919bc8dc67989d71a1a 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 
 [ -b "/dev/mapper/$2" ] && exit 0
-echo -n test >/keyfile
+printf test >/keyfile
 /sbin/cryptsetup luksOpen "$1" "$2" </keyfile
index 7b9a17179cff2fd4f53fdf5be758120b0fbfe0d8..3299aa685603d6a45f4a86874dfce74388017e36 100755 (executable)
@@ -20,7 +20,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /de
 # wait for the array to finish initailizing, otherwise this sometimes fails
 # randomly.
 mdadm -W /dev/md0
-echo -n test >keyfile
+printf test >keyfile
 cryptsetup -q luksFormat /dev/md0 /keyfile
 echo "The passphrase is test"
 set -e
index db27c5b8840845c98f520132a70685ea28afdbec..78ed7f5f238a53c3ef9a37c74d66c45a0aaad6cd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 [ -b /dev/mapper/$2 ] && exit 0
-echo -n test >/keyfile
+printf test >/keyfile
 /sbin/cryptsetup luksOpen $1 $2 </keyfile
 
index e74fe7f9ab363bc92641350640e876e979375ad3..72bc765f3021ea64ab7ee33a95bd4378a1fd3f2f 100755 (executable)
@@ -14,7 +14,7 @@ sfdisk /dev/sda <<EOF
 ,25M
 EOF
 udevadm settle
-echo -n test >keyfile
+printf test >keyfile
 cryptsetup -q luksFormat /dev/sda2 /keyfile
 cryptsetup -q luksFormat /dev/sda3 /keyfile
 cryptsetup -q luksFormat /dev/sda4 /keyfile
index db27c5b8840845c98f520132a70685ea28afdbec..78ed7f5f238a53c3ef9a37c74d66c45a0aaad6cd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 [ -b /dev/mapper/$2 ] && exit 0
-echo -n test >/keyfile
+printf test >/keyfile
 /sbin/cryptsetup luksOpen $1 $2 </keyfile
 
index db27c5b8840845c98f520132a70685ea28afdbec..78ed7f5f238a53c3ef9a37c74d66c45a0aaad6cd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 [ -b /dev/mapper/$2 ] && exit 0
-echo -n test >/keyfile
+printf test >/keyfile
 /sbin/cryptsetup luksOpen $1 $2 </keyfile
 
index 2311981d1147e1d6563576c9c94806d86f021525..a443289e3133ee27217b06a6d4392fff76c13e22 100755 (executable)
@@ -8,7 +8,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 
 stty sane
 if strstr "$CMDLINE" "rd.shell"; then
-    [ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
+    [ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
 fi
index 391279e4261b3ffc5d0c58213ce11f132db7e167..20d0effd9f54300abf64e18b66fd33a0b97fc454 100755 (executable)
@@ -5,7 +5,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
 done
 rm -f -- /etc/lvm/lvm.conf
 udevadm control --reload
-echo -n test >keyfile
+printf test >keyfile
 cryptsetup -q luksFormat /dev/sdb /keyfile
 echo "The passphrase is test"
 cryptsetup luksOpen /dev/sdb dracut_crypt_test </keyfile && \
index db27c5b8840845c98f520132a70685ea28afdbec..78ed7f5f238a53c3ef9a37c74d66c45a0aaad6cd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 [ -b /dev/mapper/$2 ] && exit 0
-echo -n test >/keyfile
+printf test >/keyfile
 /sbin/cryptsetup luksOpen $1 $2 </keyfile