From cdae5bf208f5fa6093fa34c978c5da7b5bbafc54 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <arvidjaar@gmail.com>
Date: Sun, 7 Dec 2014 14:56:17 +0300
Subject: [PATCH 132/506] Avoid use of non-portable echo -n in grub-mkconfig
util/grub-mkconfig_lib.in(version_test_gt): "echo -n" is not really needed,
final newline is stripped by command substitution.
util/grub.d/10_kfreebsd.in, util/grub.d/10_linux.in,
util/grub.d/20_linux_xen.in: change how list is built, to avoid echo -n
completely.
util/grub.d/30_os-prober.in: add spaces to printed line directly
Closes 43668.
---
ChangeLog | 11 +++++++++++
util/grub-mkconfig_lib.in | 4 ++--
util/grub.d/10_kfreebsd.in | 9 ++++++---
util/grub.d/10_linux.in | 14 ++++++++------
util/grub.d/20_linux_xen.in | 14 ++++++++------
util/grub.d/30_os-prober.in | 3 +--
6 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e5c9fd3..b23f069 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-12-07 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkconfig_lib.in (version_test_gt): Remove redundant
+ non-portable '-n' echo option.
+ * util/grub.d/10_kfreebsd.in: Change how list is built to avoid
+ non-portable 'echo -n.
+ * util/grub.d/10_linux.in: Likewise (closes 43668).
+ * util/grub.d/20_linux_xen.in: Likewise.
+ * util/grub.d/30_os-prober.in: Print spaces directly to avoid
+ non-portable 'echo -n'.
+
2014-12-07 Curtis Larsen <larsen@dixie.edu>
* grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 14fadbc..29ef865 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -246,8 +246,8 @@ version_test_gt ()
fi
case "$version_test_gt_a:$version_test_gt_b" in
*.old:*.old) ;;
- *.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
- *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
+ *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
+ *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
esac
version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b"
return "$?"
diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in
index ba7175b..65f6c32 100644
--- a/util/grub.d/10_kfreebsd.in
+++ b/util/grub.d/10_kfreebsd.in
@@ -143,9 +143,12 @@ EOF
EOF
}
-list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
- done`
+list=
+for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
+ if grub_file_is_not_garbage "$i" ; then
+ list="$list $i"
+ fi
+done
prepare_boot_cache=
boot_device_id=
title_correction_code=
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index d2e2a8f..a2a84dc 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -147,13 +147,15 @@ EOF
machine=`uname -m`
case "x$machine" in
xi?86 | xx86_64)
- list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
- done` ;;
+ list=
+ for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
+ done ;;
*)
- list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
- done` ;;
+ list=
+ for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
+ done ;;
esac
case "$machine" in
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 2e77758..de34c8d 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -137,7 +137,8 @@ EOF
EOF
}
-linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
+linux_list=
+for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
if grub_file_is_not_garbage "$i"; then
basename=$(basename $i)
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
@@ -149,9 +150,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
break
fi
done
- if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then echo -n "$i " ; fi
+ if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then linux_list="$linux_list $i" ; fi
fi
- done`
+done
if [ "x${linux_list}" = "x" ] ; then
exit 0
fi
@@ -165,9 +166,10 @@ file_is_not_sym () {
esac
}
-xen_list=`for i in /boot/xen*; do
- if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
- done`
+xen_list=
+for i in /boot/xen*; do
+ if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi
+done
prepare_boot_cache=
boot_device_id=
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 6f38c82..4ee6015 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -322,9 +322,8 @@ EOF
EOF
;;
*)
- echo -n " "
# TRANSLATORS: %s is replaced by OS name.
- gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2
+ gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2
;;
esac
done
--
2.4.3