Skip to content

Commit 2df6710

Browse files
pks-tgitster
authored andcommitted
t: adapt character translation helpers to not use Perl
We have a couple of helper functions that translate characters, e.g. from LF to NUL or NUL to 'Q' and vice versa. These helpers use Perl scripts, but they can be trivially adapted to instead use tr(1). Note that one specialty here is the handling of NUL characters in tr(1), which historically wasn't implemented correctly on all platforms. But quoting tr(1p): It was considered that automatically stripping NUL characters from the input was not correct functionality. However, the removal of -n in a later proposal does not remove the requirement that tr correctly process NUL characters in its input stream. So when tr(1) is implemented following the POSIX standard then it is expected to handle the transliteration of NUL just fine. Refactor the helpers accordingly, which allows a bunch of tests to pass when Perl is not available. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7792d32 commit 2df6710

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

t/test-lib-functions.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ test_decode_color () {
8888
}
8989

9090
lf_to_nul () {
91-
perl -pe 'y/\012/\000/'
91+
tr '\012' '\000'
9292
}
9393

9494
nul_to_q () {
95-
perl -pe 'y/\000/Q/'
95+
tr '\000' 'Q'
9696
}
9797

9898
q_to_nul () {
99-
perl -pe 'y/Q/\000/'
99+
tr 'Q' '\000'
100100
}
101101

102102
q_to_cr () {

0 commit comments

Comments
 (0)