Blame 0043-Replace-echo-n-with-printf-in-code-with-a-bin-sh-she.patch

Harald Hoyer 368a0c
From 5899f2f5163de4d68fbb35831e1f2230c22c71b3 Mon Sep 17 00:00:00 2001
Harald Hoyer 368a0c
From: Mike Gilbert <floppym@gentoo.org>
Harald Hoyer 368a0c
Date: Tue, 14 Jul 2015 22:22:14 -0400
Harald Hoyer 368a0c
Subject: [PATCH] Replace echo -n with printf in code with a /bin/sh shebang
Harald Hoyer 368a0c
Harald Hoyer 368a0c
POSIX does not mandate that echo support the -n parameter.
Harald Hoyer 368a0c
printf has more well-defined behavior.
Harald Hoyer 368a0c
---
Harald Hoyer 368a0c
 modules.d/04watchdog/watchdog-stop.sh      | 2 +-
Harald Hoyer 368a0c
 modules.d/40network/net-lib.sh             | 2 +-
Harald Hoyer 368a0c
 modules.d/45ifcfg/write-ifcfg.sh           | 2 +-
Harald Hoyer 368a0c
 modules.d/90lvm/lvm_scan.sh                | 4 ++--
Harald Hoyer 368a0c
 modules.d/95fcoe/fcoe-up.sh                | 2 +-
Harald Hoyer 368a0c
 modules.d/98usrmount/mount-usr.sh          | 2 +-
Harald Hoyer 368a0c
 modules.d/99base/dracut-lib.sh             | 6 +++---
Harald Hoyer 368a0c
 modules.d/99base/init.sh                   | 2 +-
Harald Hoyer 368a0c
 test/TEST-10-RAID/create-root.sh           | 2 +-
Harald Hoyer 368a0c
 test/TEST-10-RAID/cryptroot-ask.sh         | 2 +-
Harald Hoyer 368a0c
 test/TEST-12-RAID-DEG/create-root.sh       | 2 +-
Harald Hoyer 368a0c
 test/TEST-12-RAID-DEG/cryptroot-ask.sh     | 2 +-
Harald Hoyer 368a0c
 test/TEST-13-ENC-RAID-LVM/create-root.sh   | 2 +-
Harald Hoyer 368a0c
 test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh | 2 +-
Harald Hoyer 368a0c
 test/TEST-14-IMSM/cryptroot-ask.sh         | 2 +-
Harald Hoyer 368a0c
 test/TEST-20-NFS/client-init.sh            | 2 +-
Harald Hoyer 368a0c
 test/TEST-40-NBD/create-root.sh            | 2 +-
Harald Hoyer 368a0c
 test/TEST-40-NBD/cryptroot-ask.sh          | 2 +-
Harald Hoyer 368a0c
 18 files changed, 21 insertions(+), 21 deletions(-)
Harald Hoyer 368a0c
Harald Hoyer 368a0c
diff --git a/modules.d/04watchdog/watchdog-stop.sh b/modules.d/04watchdog/watchdog-stop.sh
Harald Hoyer 368a0c
index 91d45d6..921f969 100755
Harald Hoyer 368a0c
--- a/modules.d/04watchdog/watchdog-stop.sh
Harald Hoyer 368a0c
+++ b/modules.d/04watchdog/watchdog-stop.sh
Harald Hoyer 368a0c
@@ -1,2 +1,2 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
-[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
Harald Hoyer 368a0c
+[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
Harald Hoyer 368a0c
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
Harald Hoyer 368a0c
index a09cdaf..6c739e8 100755
Harald Hoyer 368a0c
--- a/modules.d/40network/net-lib.sh
Harald Hoyer 368a0c
+++ b/modules.d/40network/net-lib.sh
Harald Hoyer 368a0c
@@ -189,7 +189,7 @@ set_ifname() {
Harald Hoyer 368a0c
 fix_bootif() {
Harald Hoyer 368a0c
     local macaddr=${1}
Harald Hoyer 368a0c
     local IFS='-'
Harald Hoyer 368a0c
-    macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
Harald Hoyer 368a0c
+    macaddr=$(printf '%s:' ${macaddr})
Harald Hoyer 368a0c
     macaddr=${macaddr%:}
Harald Hoyer 368a0c
     # strip hardware type field from pxelinux
Harald Hoyer 368a0c
     [ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
Harald Hoyer 368a0c
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 368a0c
index fa7db27..251d684 100755
Harald Hoyer 368a0c
--- a/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 368a0c
+++ b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 368a0c
@@ -48,7 +48,7 @@ print_s390() {
Harald Hoyer 368a0c
         for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
Harald Hoyer 368a0c
             [ -e $i ] || continue
Harald Hoyer 368a0c
             channel=$(readlink -f $i)
Harald Hoyer 368a0c
-            echo -n "${channel##*/},"
Harald Hoyer 368a0c
+            printf '%s' "${channel##*/},"
Harald Hoyer 368a0c
         done
Harald Hoyer 368a0c
     })
Harald Hoyer 368a0c
     [ -n "$SUBCHANNELS" ] || return 1
Harald Hoyer 368a0c
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 368a0c
index 7495644..ead28aa 100755
Harald Hoyer 368a0c
--- a/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 368a0c
+++ b/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 368a0c
@@ -15,14 +15,14 @@ SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
Harald Hoyer 368a0c
 lvmdevs=$(
Harald Hoyer 368a0c
     for f in /tmp/.lvm_scan-*; do
Harald Hoyer 368a0c
         [ -e "$f" ] || continue
Harald Hoyer 368a0c
-        echo -n "${f##/tmp/.lvm_scan-} "
Harald Hoyer 368a0c
+        printf '%s' "${f##/tmp/.lvm_scan-} "
Harald Hoyer 368a0c
     done
Harald Hoyer 368a0c
 )
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 if [ ! -e /etc/lvm/lvm.conf ]; then
Harald Hoyer 368a0c
     {
Harald Hoyer 368a0c
         echo 'devices {';
Harald Hoyer 368a0c
-        echo -n '    filter = [ '
Harald Hoyer 368a0c
+        printf '    filter = [ '
Harald Hoyer 368a0c
         for dev in $lvmdevs; do
Harald Hoyer 368a0c
             printf '"a|^/dev/%s$|", ' $dev;
Harald Hoyer 368a0c
         done;
Harald Hoyer 368a0c
diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh
Harald Hoyer 368a0c
index 43a0ad5..950e4b6 100755
Harald Hoyer 368a0c
--- a/modules.d/95fcoe/fcoe-up.sh
Harald Hoyer 368a0c
+++ b/modules.d/95fcoe/fcoe-up.sh
Harald Hoyer 368a0c
@@ -64,7 +64,7 @@ elif [ "$netdriver" = "bnx2x" ]; then
Harald Hoyer 368a0c
     sleep 3
Harald Hoyer 368a0c
     fipvlan "$netif" -c -s
Harald Hoyer 368a0c
 else
Harald Hoyer 368a0c
-    echo -n "$netif" > /sys/module/fcoe/parameters/create
Harald Hoyer 368a0c
+    printf '%s' "$netif" > /sys/module/fcoe/parameters/create
Harald Hoyer 368a0c
 fi
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 need_shutdown
Harald Hoyer 368a0c
diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer 368a0c
index c29610f..d1a629c 100755
Harald Hoyer 368a0c
--- a/modules.d/98usrmount/mount-usr.sh
Harald Hoyer 368a0c
+++ b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer 368a0c
@@ -12,7 +12,7 @@ filtersubvol() {
Harald Hoyer 368a0c
     while [ $# -gt 0 ]; do
Harald Hoyer 368a0c
         case $1 in
Harald Hoyer 368a0c
             subvol\=*) :;;
Harald Hoyer 368a0c
-            *) echo -n "${1}," ;;
Harald Hoyer 368a0c
+            *) printf '%s' "${1}," ;;
Harald Hoyer 368a0c
         esac
Harald Hoyer 368a0c
         shift
Harald Hoyer 368a0c
     done
Harald Hoyer 368a0c
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 368a0c
index cd1f49f..5ec7b23 100755
Harald Hoyer 368a0c
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 368a0c
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 368a0c
@@ -298,7 +298,7 @@ _dogetargs() {
Harald Hoyer 368a0c
         fi
Harald Hoyer 368a0c
     done
Harald Hoyer 368a0c
     if [ -n "$_found" ]; then
Harald Hoyer 368a0c
-        [ $# -gt 0 ] && echo -n "$@"
Harald Hoyer 368a0c
+        [ $# -gt 0 ] && printf '%s' "$*"
Harald Hoyer 368a0c
         return 0
Harald Hoyer 368a0c
     fi
Harald Hoyer 368a0c
     return 1;
Harald Hoyer 368a0c
@@ -329,9 +329,9 @@ getargs() {
Harald Hoyer 368a0c
     done
Harald Hoyer 368a0c
     if [ -n "$_gfound" ]; then
Harald Hoyer 368a0c
         if [ $# -gt 0 ]; then
Harald Hoyer 368a0c
-            echo -n "$@"
Harald Hoyer 368a0c
+            printf '%s' "$*"
Harald Hoyer 368a0c
         else
Harald Hoyer 368a0c
-            echo -n 1
Harald Hoyer 368a0c
+            printf 1
Harald Hoyer 368a0c
         fi
Harald Hoyer 368a0c
         debug_on
Harald Hoyer 368a0c
         return 0
Harald Hoyer 368a0c
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer 368a0c
index f96dbb5..a59e8ea 100755
Harald Hoyer 368a0c
--- a/modules.d/99base/init.sh
Harald Hoyer 368a0c
+++ b/modules.d/99base/init.sh
Harald Hoyer 368a0c
@@ -253,7 +253,7 @@ while :; do
Harald Hoyer 368a0c
 done
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 {
Harald Hoyer 368a0c
-    echo -n "Mounted root filesystem "
Harald Hoyer 368a0c
+    printf "Mounted root filesystem "
Harald Hoyer 368a0c
     while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
Harald Hoyer 368a0c
 } | vinfo
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
diff --git a/test/TEST-10-RAID/create-root.sh b/test/TEST-10-RAID/create-root.sh
Harald Hoyer 368a0c
index a7e56a5..7b5f2a7 100755
Harald Hoyer 368a0c
--- a/test/TEST-10-RAID/create-root.sh
Harald Hoyer 368a0c
+++ b/test/TEST-10-RAID/create-root.sh
Harald Hoyer 368a0c
@@ -18,7 +18,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /d
Harald Hoyer 368a0c
 # randomly.
Harald Hoyer 368a0c
 mdadm -W /dev/md0
Harald Hoyer 368a0c
 set -e
Harald Hoyer 368a0c
-echo -n test >keyfile
Harald Hoyer 368a0c
+printf test >keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/md0 /keyfile
Harald Hoyer 368a0c
 echo "The passphrase is test"
Harald Hoyer 368a0c
 cryptsetup luksOpen /dev/md0 dracut_crypt_test 
Harald Hoyer 368a0c
diff --git a/test/TEST-10-RAID/cryptroot-ask.sh b/test/TEST-10-RAID/cryptroot-ask.sh
Harald Hoyer 368a0c
index 407d067..c39eff6 100755
Harald Hoyer 368a0c
--- a/test/TEST-10-RAID/cryptroot-ask.sh
Harald Hoyer 368a0c
+++ b/test/TEST-10-RAID/cryptroot-ask.sh
Harald Hoyer 368a0c
@@ -1,5 +1,5 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 [ -b "/dev/mapper/$2" ] && exit 0
Harald Hoyer 368a0c
-echo -n test >/keyfile
Harald Hoyer 368a0c
+printf test >/keyfile
Harald Hoyer 368a0c
 /sbin/cryptsetup luksOpen "$1" "$2" 
Harald Hoyer 368a0c
diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 368a0c
index 7b9a171..3299aa6 100755
Harald Hoyer 368a0c
--- a/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 368a0c
+++ b/test/TEST-12-RAID-DEG/create-root.sh
Harald Hoyer 368a0c
@@ -20,7 +20,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /de
Harald Hoyer 368a0c
 # wait for the array to finish initailizing, otherwise this sometimes fails
Harald Hoyer 368a0c
 # randomly.
Harald Hoyer 368a0c
 mdadm -W /dev/md0
Harald Hoyer 368a0c
-echo -n test >keyfile
Harald Hoyer 368a0c
+printf test >keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/md0 /keyfile
Harald Hoyer 368a0c
 echo "The passphrase is test"
Harald Hoyer 368a0c
 set -e
Harald Hoyer 368a0c
diff --git a/test/TEST-12-RAID-DEG/cryptroot-ask.sh b/test/TEST-12-RAID-DEG/cryptroot-ask.sh
Harald Hoyer 368a0c
index db27c5b..78ed7f5 100755
Harald Hoyer 368a0c
--- a/test/TEST-12-RAID-DEG/cryptroot-ask.sh
Harald Hoyer 368a0c
+++ b/test/TEST-12-RAID-DEG/cryptroot-ask.sh
Harald Hoyer 368a0c
@@ -1,6 +1,6 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 [ -b /dev/mapper/$2 ] && exit 0
Harald Hoyer 368a0c
-echo -n test >/keyfile
Harald Hoyer 368a0c
+printf test >/keyfile
Harald Hoyer 368a0c
 /sbin/cryptsetup luksOpen $1 $2 
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
diff --git a/test/TEST-13-ENC-RAID-LVM/create-root.sh b/test/TEST-13-ENC-RAID-LVM/create-root.sh
Harald Hoyer 368a0c
index e74fe7f..72bc765 100755
Harald Hoyer 368a0c
--- a/test/TEST-13-ENC-RAID-LVM/create-root.sh
Harald Hoyer 368a0c
+++ b/test/TEST-13-ENC-RAID-LVM/create-root.sh
Harald Hoyer 368a0c
@@ -14,7 +14,7 @@ sfdisk /dev/sda <
Harald Hoyer 368a0c
 ,25M
Harald Hoyer 368a0c
 EOF
Harald Hoyer 368a0c
 udevadm settle
Harald Hoyer 368a0c
-echo -n test >keyfile
Harald Hoyer 368a0c
+printf test >keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/sda2 /keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/sda3 /keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/sda4 /keyfile
Harald Hoyer 368a0c
diff --git a/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh b/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
Harald Hoyer 368a0c
index db27c5b..78ed7f5 100755
Harald Hoyer 368a0c
--- a/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
Harald Hoyer 368a0c
+++ b/test/TEST-13-ENC-RAID-LVM/cryptroot-ask.sh
Harald Hoyer 368a0c
@@ -1,6 +1,6 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 [ -b /dev/mapper/$2 ] && exit 0
Harald Hoyer 368a0c
-echo -n test >/keyfile
Harald Hoyer 368a0c
+printf test >/keyfile
Harald Hoyer 368a0c
 /sbin/cryptsetup luksOpen $1 $2 
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
diff --git a/test/TEST-14-IMSM/cryptroot-ask.sh b/test/TEST-14-IMSM/cryptroot-ask.sh
Harald Hoyer 368a0c
index db27c5b..78ed7f5 100755
Harald Hoyer 368a0c
--- a/test/TEST-14-IMSM/cryptroot-ask.sh
Harald Hoyer 368a0c
+++ b/test/TEST-14-IMSM/cryptroot-ask.sh
Harald Hoyer 368a0c
@@ -1,6 +1,6 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 [ -b /dev/mapper/$2 ] && exit 0
Harald Hoyer 368a0c
-echo -n test >/keyfile
Harald Hoyer 368a0c
+printf test >/keyfile
Harald Hoyer 368a0c
 /sbin/cryptsetup luksOpen $1 $2 
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
diff --git a/test/TEST-20-NFS/client-init.sh b/test/TEST-20-NFS/client-init.sh
Harald Hoyer 368a0c
index 2311981..a443289 100755
Harald Hoyer 368a0c
--- a/test/TEST-20-NFS/client-init.sh
Harald Hoyer 368a0c
+++ b/test/TEST-20-NFS/client-init.sh
Harald Hoyer 368a0c
@@ -8,7 +8,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 stty sane
Harald Hoyer 368a0c
 if strstr "$CMDLINE" "rd.shell"; then
Harald Hoyer 368a0c
-    [ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
Harald Hoyer 368a0c
+    [ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
Harald Hoyer 368a0c
 	strstr "$(setsid --help)" "control" && CTTY="-c"
Harald Hoyer 368a0c
 	setsid $CTTY sh -i
Harald Hoyer 368a0c
 fi
Harald Hoyer 368a0c
diff --git a/test/TEST-40-NBD/create-root.sh b/test/TEST-40-NBD/create-root.sh
Harald Hoyer 368a0c
index 391279e..20d0eff 100755
Harald Hoyer 368a0c
--- a/test/TEST-40-NBD/create-root.sh
Harald Hoyer 368a0c
+++ b/test/TEST-40-NBD/create-root.sh
Harald Hoyer 368a0c
@@ -5,7 +5,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
Harald Hoyer 368a0c
 done
Harald Hoyer 368a0c
 rm -f -- /etc/lvm/lvm.conf
Harald Hoyer 368a0c
 udevadm control --reload
Harald Hoyer 368a0c
-echo -n test >keyfile
Harald Hoyer 368a0c
+printf test >keyfile
Harald Hoyer 368a0c
 cryptsetup -q luksFormat /dev/sdb /keyfile
Harald Hoyer 368a0c
 echo "The passphrase is test"
Harald Hoyer 368a0c
 cryptsetup luksOpen /dev/sdb dracut_crypt_test 
Harald Hoyer 368a0c
diff --git a/test/TEST-40-NBD/cryptroot-ask.sh b/test/TEST-40-NBD/cryptroot-ask.sh
Harald Hoyer 368a0c
index db27c5b..78ed7f5 100755
Harald Hoyer 368a0c
--- a/test/TEST-40-NBD/cryptroot-ask.sh
Harald Hoyer 368a0c
+++ b/test/TEST-40-NBD/cryptroot-ask.sh
Harald Hoyer 368a0c
@@ -1,6 +1,6 @@
Harald Hoyer 368a0c
 #!/bin/sh
Harald Hoyer 368a0c
 
Harald Hoyer 368a0c
 [ -b /dev/mapper/$2 ] && exit 0
Harald Hoyer 368a0c
-echo -n test >/keyfile
Harald Hoyer 368a0c
+printf test >/keyfile
Harald Hoyer 368a0c
 /sbin/cryptsetup luksOpen $1 $2 
Harald Hoyer 368a0c