Re: [PATCH 1/3] Modify tr expressions so that xpg4/tr handles it on Solaris
From: Eric Sunshine <hidden>
Date: 2016-06-15 23:05:49
On Sun, Jul 19, 2015 at 2:00 PM, Ben Walton [off-list ref] wrote:
quoted hunk ↗ jump to hunk
It seems that xpg4/tr mishandles some strings involving [ not followed by a character class: % echo '[::1]' | /usr/xpg4/bin/tr -d '[]' [::1 % echo '[::1]' | /usr/xpg4/bin/tr -d '[' usr/xpg4/bin/tr: Bad string. This was breaking two tests. To fix the issue, use the octal representations of [ and ] instead. Reference the octal expression as a newly exported variable so that it's shared across tests and more easily understood when reading it. Signed-off-by: Ben Walton <redacted> ---diff --git a/t/test-lib.sh b/t/test-lib.sh index 39da9c2..6b5b6cd 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh@@ -173,7 +173,10 @@ LF=' # when case-folding filenames u200c=$(printf '\342\200\214') -export _x05 _x40 _z40 LF u200c +# [ and ], for use by tr commands. +squarebrackets="\133\135"
While it's true that the reader may be able to consult the commit message to learn more about "squarebrackets" and "tr", this might be one of those cases where either a more explanatory in-code comment is warranted or the comment should be dropped altogether, since the the current comment is not illuminating. I'd vote for expanding the comment a bit to mention "some versions of Solaris 'tr'" and a short description of the misbehavior. Also, Hannes wondered how Solaris 'tr' would react to '[][]'. Were you able to test that or the alternative '[[]]'?