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