712866
From d6b9aac6d0f8d007fa9ebf073a665857d8b0b0b4 Mon Sep 17 00:00:00 2001
712866
From: Mike Gilbert <floppym@gentoo.org>
712866
Date: Tue, 14 Jul 2015 22:22:14 -0400
712866
Subject: [PATCH] Replace echo -n with printf in code with a /bin/sh shebang
712866
712866
POSIX does not mandate that echo support the -n parameter.
712866
printf has more well-defined behavior.
712866
712866
(cherry picked from commit 5899f2f5163de4d68fbb35831e1f2230c22c71b3)
712866
---
712866
 modules.d/04watchdog/watchdog-stop.sh      | 2 +-
712866
 modules.d/40network/net-lib.sh             | 2 +-
712866
 modules.d/45ifcfg/write-ifcfg.sh           | 2 +-
712866
 modules.d/90lvm/lvm_scan.sh                | 4 ++--
712866
 modules.d/98usrmount/mount-usr.sh          | 2 +-
712866
 modules.d/99base/dracut-lib.sh             | 6 ++++--
712866
 modules.d/99base/init.sh                   | 4 ++--
712866
 test/TEST-10-RAID/create-root.sh           | 2 +-
712866
 test/TEST-10-RAID/cryptroot-ask.sh         | 2 +-
712866
 test/TEST-12-RAID-DEG/create-root.sh       | 2 +-
712866
 test/TEST-12-RAID-DEG/cryptroot-ask.sh     | 2 +-
712866
 test/TEST-13-ENC-RAID-LVM/create-root.sh   | 2 +-
712866
 test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh | 2 +-
712866
 test/TEST-14-IMSM/cryptroot-ask.sh         | 2 +-
712866
 test/TEST-40-NBD/create-root.sh            | 2 +-
712866
 test/TEST-40-NBD/cryptroot-ask.sh          | 2 +-
712866
 16 files changed, 21 insertions(+), 19 deletions(-)
712866
712866
diff --git a/modules.d/04watchdog/watchdog-stop.sh b/modules.d/04watchdog/watchdog-stop.sh
5c6c2a
index 91d45d63..921f9695 100755
712866
--- a/modules.d/04watchdog/watchdog-stop.sh
712866
+++ b/modules.d/04watchdog/watchdog-stop.sh
712866
@@ -1,2 +1,2 @@
712866
 #!/bin/sh
712866
-[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
712866
+[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
5c6c2a
index 07ea5709..f91d1691 100755
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -211,7 +211,7 @@ set_ifname() {
712866
 fix_bootif() {
712866
     local macaddr=${1}
712866
     local IFS='-'
712866
-    macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
712866
+    macaddr=$(printf '%s:' ${macaddr})
712866
     macaddr=${macaddr%:}
712866
     # strip hardware type field from pxelinux
712866
     [ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
712866
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
5c6c2a
index f3a1c109..a5114be1 100755
712866
--- a/modules.d/45ifcfg/write-ifcfg.sh
712866
+++ b/modules.d/45ifcfg/write-ifcfg.sh
712866
@@ -50,7 +50,7 @@ print_s390() {
712866
         for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
712866
             [ -e $i ] || continue
712866
             channel=$(readlink -f $i)
712866
-            echo -n "${channel##*/},"
712866
+            printf '%s' "${channel##*/},"
712866
         done
712866
     })
712866
     [ -n "$SUBCHANNELS" ] || return 1
712866
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
5c6c2a
index f87831c7..ae6f177b 100755
712866
--- a/modules.d/90lvm/lvm_scan.sh
712866
+++ b/modules.d/90lvm/lvm_scan.sh
712866
@@ -17,14 +17,14 @@ SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
712866
 lvmdevs=$(
712866
     for f in /tmp/.lvm_scan-*; do
712866
         [ -e "$f" ] || continue
712866
-        echo -n "${f##/tmp/.lvm_scan-} "
712866
+        printf '%s' "${f##/tmp/.lvm_scan-} "
712866
     done
712866
 )
712866
 
712866
 if [ ! -e /etc/lvm/lvm.conf ]; then
712866
     {
712866
         echo 'devices {';
712866
-        echo -n '    filter = [ '
712866
+        printf '    filter = [ '
712866
         for dev in $lvmdevs; do
712866
             printf '"a|^/dev/%s$|", ' $dev;
712866
         done;
712866
diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh
5c6c2a
index de7dcc22..8026db3c 100755
712866
--- a/modules.d/98usrmount/mount-usr.sh
712866
+++ b/modules.d/98usrmount/mount-usr.sh
712866
@@ -14,7 +14,7 @@ filtersubvol() {
712866
     while [ $# -gt 0 ]; do
712866
         case $1 in
712866
             subvol\=*) :;;
712866
-            *) echo -n "${1}," ;;
712866
+            *) printf '%s' "${1}," ;;
712866
         esac
712866
         shift
712866
     done
712866
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
5c6c2a
index 71dcedcf..c2b6108a 100755
712866
--- a/modules.d/99base/dracut-lib.sh
712866
+++ b/modules.d/99base/dracut-lib.sh
712866
@@ -295,7 +295,7 @@ _dogetargs() {
712866
         fi
712866
     done
712866
     if [ -n "$_found" ]; then
712866
-        [ $# -gt 0 ] && echo -n "$@"
712866
+        [ $# -gt 0 ] && printf '%s' "$*"
712866
         return 0
712866
     fi
712866
     return 1;
712866
@@ -326,7 +326,9 @@ getargs() {
712866
     done
712866
     if [ -n "$_gfound" ]; then
712866
         if [ $# -gt 0 ]; then
712866
-            echo -n "$@"
712866
+            printf '%s' "$*"
712866
+        else
712866
+            printf 1
712866
         fi
712866
         debug_on
712866
         return 0
712866
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
5c6c2a
index dcc62d2a..a07d0f94 100755
712866
--- a/modules.d/99base/init.sh
712866
+++ b/modules.d/99base/init.sh
712866
@@ -253,8 +253,8 @@ while :; do
712866
 done
712866
 
712866
 {
712866
-    echo -n "Mounted root filesystem "
712866
-    while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
712866
+    printf "Mounted root filesystem "
712866
+    while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
712866
 } | vinfo
712866
 
712866
 # pre pivot scripts are sourced just before we doing cleanup and switch over
712866
diff --git a/test/TEST-10-RAID/create-root.sh b/test/TEST-10-RAID/create-root.sh
5c6c2a
index 50554132..be7a3a00 100755
712866
--- a/test/TEST-10-RAID/create-root.sh
712866
+++ b/test/TEST-10-RAID/create-root.sh
712866
@@ -18,7 +18,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /d
712866
 # randomly.
712866
 mdadm -W /dev/md0
712866
 set -e
712866
-echo -n test >keyfile
712866
+printf test >keyfile
712866
 cryptsetup -q luksFormat /dev/md0 /keyfile
712866
 echo "The passphrase is test"
712866
 cryptsetup luksOpen /dev/md0 dracut_crypt_test 
712866
diff --git a/test/TEST-10-RAID/cryptroot-ask.sh b/test/TEST-10-RAID/cryptroot-ask.sh
5c6c2a
index 407d0677..c39eff6e 100755
712866
--- a/test/TEST-10-RAID/cryptroot-ask.sh
712866
+++ b/test/TEST-10-RAID/cryptroot-ask.sh
712866
@@ -1,5 +1,5 @@
712866
 #!/bin/sh
712866
 
712866
 [ -b "/dev/mapper/$2" ] && exit 0
712866
-echo -n test >/keyfile
712866
+printf test >/keyfile
712866
 /sbin/cryptsetup luksOpen "$1" "$2" 
712866
diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh
5c6c2a
index 699c27c0..5709060f 100755
712866
--- a/test/TEST-12-RAID-DEG/create-root.sh
712866
+++ b/test/TEST-12-RAID-DEG/create-root.sh
712866
@@ -20,7 +20,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /de
712866
 # wait for the array to finish initailizing, otherwise this sometimes fails
712866
 # randomly.
712866
 mdadm -W /dev/md0
712866
-echo -n test >keyfile
712866
+printf test >keyfile
712866
 cryptsetup -q luksFormat /dev/md0 /keyfile
712866
 echo "The passphrase is test"
712866
 set -e
712866
diff --git a/test/TEST-12-RAID-DEG/cryptroot-ask.sh b/test/TEST-12-RAID-DEG/cryptroot-ask.sh
5c6c2a
index db27c5b8..78ed7f5f 100755
712866
--- a/test/TEST-12-RAID-DEG/cryptroot-ask.sh
712866
+++ b/test/TEST-12-RAID-DEG/cryptroot-ask.sh
712866
@@ -1,6 +1,6 @@
712866
 #!/bin/sh
712866
 
712866
 [ -b /dev/mapper/$2 ] && exit 0
712866
-echo -n test >/keyfile
712866
+printf test >/keyfile
712866
 /sbin/cryptsetup luksOpen $1 $2 
712866
 
712866
diff --git a/test/TEST-13-ENC-RAID-LVM/create-root.sh b/test/TEST-13-ENC-RAID-LVM/create-root.sh
5c6c2a
index af83c238..4e10461f 100755
712866
--- a/test/TEST-13-ENC-RAID-LVM/create-root.sh
712866
+++ b/test/TEST-13-ENC-RAID-LVM/create-root.sh
712866
@@ -14,7 +14,7 @@ sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <
712866
 ,800
712866
 EOF
712866
 udevadm settle
712866
-echo -n test >keyfile
712866
+printf test >keyfile
712866
 cryptsetup -q luksFormat /dev/sda2 /keyfile
712866
 cryptsetup -q luksFormat /dev/sda3 /keyfile
712866
 cryptsetup -q luksFormat /dev/sda4 /keyfile
712866
diff --git a/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh b/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
5c6c2a
index db27c5b8..78ed7f5f 100755
712866
--- a/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
712866
+++ b/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
712866
@@ -1,6 +1,6 @@
712866
 #!/bin/sh
712866
 
712866
 [ -b /dev/mapper/$2 ] && exit 0
712866
-echo -n test >/keyfile
712866
+printf test >/keyfile
712866
 /sbin/cryptsetup luksOpen $1 $2 
712866
 
712866
diff --git a/test/TEST-14-IMSM/cryptroot-ask.sh b/test/TEST-14-IMSM/cryptroot-ask.sh
5c6c2a
index db27c5b8..78ed7f5f 100755
712866
--- a/test/TEST-14-IMSM/cryptroot-ask.sh
712866
+++ b/test/TEST-14-IMSM/cryptroot-ask.sh
712866
@@ -1,6 +1,6 @@
712866
 #!/bin/sh
712866
 
712866
 [ -b /dev/mapper/$2 ] && exit 0
712866
-echo -n test >/keyfile
712866
+printf test >/keyfile
712866
 /sbin/cryptsetup luksOpen $1 $2 
712866
 
712866
diff --git a/test/TEST-40-NBD/create-root.sh b/test/TEST-40-NBD/create-root.sh
5c6c2a
index cb27a604..4df472a8 100755
712866
--- a/test/TEST-40-NBD/create-root.sh
712866
+++ b/test/TEST-40-NBD/create-root.sh
712866
@@ -5,7 +5,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
712866
 done
712866
 rm -f -- /etc/lvm/lvm.conf
712866
 udevadm control --reload
712866
-echo -n test >keyfile
712866
+printf test >keyfile
712866
 cryptsetup -q luksFormat /dev/sdb /keyfile
712866
 echo "The passphrase is test"
712866
 cryptsetup luksOpen /dev/sdb dracut_crypt_test 
712866
diff --git a/test/TEST-40-NBD/cryptroot-ask.sh b/test/TEST-40-NBD/cryptroot-ask.sh
5c6c2a
index db27c5b8..78ed7f5f 100755
712866
--- a/test/TEST-40-NBD/cryptroot-ask.sh
712866
+++ b/test/TEST-40-NBD/cryptroot-ask.sh
712866
@@ -1,6 +1,6 @@
712866
 #!/bin/sh
712866
 
712866
 [ -b /dev/mapper/$2 ] && exit 0
712866
-echo -n test >/keyfile
712866
+printf test >/keyfile
712866
 /sbin/cryptsetup luksOpen $1 $2 
712866