[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/23] scripts/hxtool: fix undefined behavour of echo
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 15/23] scripts/hxtool: fix undefined behavour of echo |
Date: |
Fri, 28 Oct 2016 18:18:46 +0300 |
From: Daniel Shahaf <address@hidden>
Avoid undefined behaviour of echo(1) with backslashes in arguments
The behaviour is implementation-defined, different /bin/sh's behave
differently.
Signed-off-by: Daniel Shahaf <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
scripts/hxtool | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/scripts/hxtool b/scripts/hxtool
index 995bb7f..04f7d7b 100644
--- a/scripts/hxtool
+++ b/scripts/hxtool
@@ -26,32 +26,32 @@ hxtotexi()
;;
STEXI*)
if test $flag -eq 1 ; then
- echo "line $line: syntax error: expected ETEXI, found $str" >&2
+ printf "line %d: syntax error: expected ETEXI, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
flag=1
;;
ETEXI*)
if test $flag -ne 1 ; then
- echo "line $line: syntax error: expected STEXI, found $str" >&2
+ printf "line %d: syntax error: expected STEXI, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
flag=0
;;
SQMP*|EQMP*)
if test $flag -eq 1 ; then
- echo "line $line: syntax error: expected ETEXI, found $str" >&2
+ printf "line %d: syntax error: expected ETEXI, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
;;
DEFHEADING*)
- echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
+ printf '%s\n' "$(expr "$str" : "DEFHEADING(\(.*\))")"
;;
ARCHHEADING*)
- echo "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
+ printf '%s\n' "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
;;
*)
- test $flag -eq 1 && echo "$str"
+ test $flag -eq 1 && printf '%s\n' "$str"
;;
esac
line=$((line+1))
@@ -69,26 +69,26 @@ hxtoqmp()
;;
SQMP*)
if test $flag -eq 1 ; then
- echo "line $line: syntax error: expected EQMP, found $str" >&2
+ printf "line %d: syntax error: expected EQMP, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
flag=1
;;
EQMP*)
if test $flag -ne 1 ; then
- echo "line $line: syntax error: expected SQMP, found $str" >&2
+ printf "line %d: syntax error: expected SQMP, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
flag=0
;;
STEXI*|ETEXI*)
if test $flag -eq 1 ; then
- echo "line $line: syntax error: expected EQMP, found $str" >&2
+ printf "line %d: syntax error: expected EQMP, found '%s'\n"
"$line" "$str" >&2
exit 1
fi
;;
*)
- test $flag -eq 1 && echo "$str"
+ test $flag -eq 1 && printf '%s\n' "$str"
;;
esac
line=$((line+1))
--
2.1.4
- [Qemu-devel] [PULL 19/23] qemu-ga: Remove stray 'q' in documentation, (continued)
- [Qemu-devel] [PULL 19/23] qemu-ga: Remove stray 'q' in documentation, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 06/23] target-lm32: disable asm logging via LOG_DIS(), Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 17/23] s390: avoid always-true comparison in s390_pci_generate_fid(), Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 11/23] colo-compare: remove unused struct CompareChardevProps and 'props' variable, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 13/23] usb: Change *_exitfn return type from int to void, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 04/23] target-lm32: fix LOG_DIS operand order, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 03/23] target-lm32: fix style issue, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 18/23] Makefile: Fix help text for target 'installer', Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 23/23] Fix build for less common build directories names, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 20/23] monitor: deprecate 'default' option, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 15/23] scripts/hxtool: fix undefined behavour of echo,
Michael Tokarev <=
- [Qemu-devel] [PULL 16/23] migration: Remove unneeded NULL check from migrate_fd_error(), Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 14/23] qemu-options.hx: set: fix copy-paste error, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 21/23] scripts/clean-includes: added duplicate #include check, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 10/23] milkymist-pfpu: fix potential integer overflow, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 09/23] hw/block/nvme: Simplify if-statements a little bit, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 12/23] MAINTAINERS: qemu-trivial information, Michael Tokarev, 2016/10/28
- [Qemu-devel] [PULL 22/23] clean-up: removed duplicate #includes, Michael Tokarev, 2016/10/28
- Re: [Qemu-devel] [PULL 00/23] Trivial patches for 2016-10-28, Peter Maydell, 2016/10/31