summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2014-11-09 09:26:30 -0800
committerJim Meyering <meyering@fb.com>2014-11-09 09:34:25 -0800
commit0604c6de0186c21724546ece7fd19cf73617f8af (patch)
treed0925258fd1bcb7941575ce0812cb26cc7019268
parent2ac355101d867f3231fd62ee131c0c98bb2eafa1 (diff)
downloadgrep-0604c6de0186c21724546ece7fd19cf73617f8af.tar.gz
tests: avoid hex_printf_ portability problems
* tests/init.cfg (hex_printf_): Spell out a-f and A-F, for non-C locales, ensure that the input to sed is newline-terminated, and quote the final octal format string. Suggestions from Paul Eggert.
-rw-r--r--tests/init.cfg6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/init.cfg b/tests/init.cfg
index e7a23893..8c71008f 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -159,8 +159,10 @@ or use the shortcut target of the toplevel Makefile,
# sequence of four-byte strings \xHH where each H is a hexadecimal byte.
hex_printf_()
{
- printf $(printf '\\%o' \
- $(printf %s "$1"|sed 's,\\x\([0-9a-fA-F][0-9a-fA-F]\), 0x\1,g'))
+ local octal_fmt=$(printf '\\%o' \
+ $(printf '%s\n' "$1" \
+ | sed 's,\\x\([0-9abcdefABCDEF][0-9abcdefABCDEF]\), 0x\1,g'))
+ printf "$octal_fmt"
}
# Wrap tr so that it always runs in the C locale.