Skip to content

Commit f985487

Browse files
drafnelgitster
authored andcommitted
t/t7008: workaround broken handling of \000 by printf on IRIX
On IRIX 6.5, the printf utility in /usr/bin does not appear to handle the \ddd notation according to POSIX. This printf appears to halt processing of the string argument and ignore any additional characters in the string. Work around this flaw by replacing the \000's with 'Q' and using the q_to_nul helper function provided by test-lib.sh This problem with printf is not apparent when using the Bash shell since Bash implements a POSIX compatible printf function internally. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 154adcf commit f985487

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

t/t7008-grep-binary.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_description='git grep in binary files'
55
. ./test-lib.sh
66

77
test_expect_success 'setup' "
8-
printf 'binary\000file\n' >a &&
8+
echo 'binaryQfile' | q_to_nul >a &&
99
git add a &&
1010
git commit -m.
1111
"
@@ -70,32 +70,32 @@ test_expect_failure 'git grep .fi a' '
7070
'
7171

7272
test_expect_success 'git grep -F y<NUL>f a' "
73-
printf 'y\000f' >f &&
73+
printf 'yQf' | q_to_nul >f &&
7474
git grep -f f -F a
7575
"
7676

7777
test_expect_success 'git grep -F y<NUL>x a' "
78-
printf 'y\000x' >f &&
78+
printf 'yQx' | q_to_nul >f &&
7979
test_must_fail git grep -f f -F a
8080
"
8181

8282
test_expect_success 'git grep -Fi Y<NUL>f a' "
83-
printf 'Y\000f' >f &&
83+
printf 'YQf' | q_to_nul >f &&
8484
git grep -f f -Fi a
8585
"
8686

8787
test_expect_failure 'git grep -Fi Y<NUL>x a' "
88-
printf 'Y\000x' >f &&
88+
printf 'YQx' | q_to_nul >f &&
8989
test_must_fail git grep -f f -Fi a
9090
"
9191

9292
test_expect_success 'git grep y<NUL>f a' "
93-
printf 'y\000f' >f &&
93+
printf 'yQf' | q_to_nul >f &&
9494
git grep -f f a
9595
"
9696

9797
test_expect_failure 'git grep y<NUL>x a' "
98-
printf 'y\000x' >f &&
98+
printf 'yQx' | q_to_nul >f &&
9999
test_must_fail git grep -f f a
100100
"
101101

0 commit comments

Comments
 (0)