]> 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)
committerHarald Hoyer <harald@redhat.com>
Wed, 29 Jun 2016 09:40:14 +0000 (11:40 +0200)
POSIX does not mandate that echo support the -n parameter.
printf has more well-defined behavior.

(cherry picked from commit 5899f2f5163de4d68fbb35831e1f2230c22c71b3)

16 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/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-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 07ea5709edfbb2d85fc42e4c6157afd52e7b24ec..f91d16916706778c845f00a840e2414436dfaf5f 100755 (executable)
@@ -211,7 +211,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 f3a1c1095288e9c4df9ee6200a90bcc9a4acb620..a5114be1bc9b7cecb079be26ffb0ef005b816717 100755 (executable)
@@ -50,7 +50,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 f87831c763c8975e36a39c5f76e32b80ce7acde4..ae6f177b381cb453197ea63367b01630dd705c27 100755 (executable)
@@ -17,14 +17,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 de7dcc2276a91cd274ac8c85bc9611a792ed683b..8026db3c0d2b45b9d90f0a18b9e18b37a06d505e 100755 (executable)
@@ -14,7 +14,7 @@ filtersubvol() {
     while [ $# -gt 0 ]; do
         case $1 in
             subvol\=*) :;;
-            *) echo -n "${1}," ;;
+            *) printf '%s' "${1}," ;;
         esac
         shift
     done
index 71dcedcf3669bae575929a0f89b4f21522a6eb86..c2b6108a154815bc62f05a8d1f4b24657967198b 100755 (executable)
@@ -295,7 +295,7 @@ _dogetargs() {
         fi
     done
     if [ -n "$_found" ]; then
-        [ $# -gt 0 ] && echo -n "$@"
+        [ $# -gt 0 ] && printf '%s' "$*"
         return 0
     fi
     return 1;
@@ -326,7 +326,9 @@ getargs() {
     done
     if [ -n "$_gfound" ]; then
         if [ $# -gt 0 ]; then
-            echo -n "$@"
+            printf '%s' "$*"
+        else
+            printf 1
         fi
         debug_on
         return 0
index dcc62d2aba4bff58a2f2dc4ff852dec286eea29f..a07d0f9470a137f30a7e038b151b02caf3aef190 100755 (executable)
@@ -253,8 +253,8 @@ while :; do
 done
 
 {
-    echo -n "Mounted root filesystem "
-    while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
+    printf "Mounted root filesystem "
+    while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
 } | vinfo
 
 # pre pivot scripts are sourced just before we doing cleanup and switch over
index 505541321fda2a1705ece4d51a8eb51a37299ce1..be7a3a00b05ceb39872602b4ce22ca0f9bc92d3a 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 699c27c085670f7dba68cc3dbcbeba71fc37f71d..5709060f8a810313b11c5930a0077ae12366c931 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 af83c23871a7e5be43bb2f0d7e5f5b38629bc8b2..4e10461fab6f11bb37f781e634cc95937621d7d2 100755 (executable)
@@ -14,7 +14,7 @@ sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF
 ,800
 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 cb27a60486cc9c946a929397b4cc941e29819df7..4df472a888ae4ead605196a66d0f09274452a024 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