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