Skip to content

Commit

Permalink
t0028: eliminate non-standard usage of printf
Browse files Browse the repository at this point in the history
man 1p printf:
   In addition to the escape sequences shown in the Base Definitions
   volume of POSIX.1‐2008, Chapter 5, File Format Notation ('\\',
   '\a', '\b', '\f', '\n', '\r', '\t', '\v'), "\ddd", where ddd is a
   one, two, or three-digit octal number, shall be written as a byte
   with the numeric value specified by the octal number.

printf '\xfe\xff' is an extension of some shell.
Dash, a popular yet simple shell, do not implement this extension.

This wasn't caught by most people running the tests, even though
common shells like dash don't handle hex escapes, because their
systems don't trigger the NO_UTF16_BOM prereq. But systems with musl
libc do; when combined with dash, the test fails.

Correct it.

Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
sgn authored and gitster committed Nov 7, 2019
1 parent da72936 commit 99b2ba3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions t/t0028-working-tree-encoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ test_lazy_prereq NO_UTF32_BOM '
write_utf16 () {
if test_have_prereq NO_UTF16_BOM
then
printf '\xfe\xff'
printf '\376\377'
fi &&
iconv -f UTF-8 -t UTF-16
}

write_utf32 () {
if test_have_prereq NO_UTF32_BOM
then
printf '\x00\x00\xfe\xff'
printf '\0\0\376\377'
fi &&
iconv -f UTF-8 -t UTF-32
}
Expand Down

0 comments on commit 99b2ba3

Please sign in to comment.