diff options
author | Jim Meyering <meyering@fb.com> | 2014-11-09 09:26:30 -0800 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2014-11-09 09:34:25 -0800 |
commit | 0604c6de0186c21724546ece7fd19cf73617f8af (patch) | |
tree | d0925258fd1bcb7941575ce0812cb26cc7019268 /tests/init.cfg | |
parent | 2ac355101d867f3231fd62ee131c0c98bb2eafa1 (diff) | |
download | grep-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.
Diffstat (limited to 'tests/init.cfg')
-rw-r--r-- | tests/init.cfg | 6 |
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. |