{"thread":{"id":"39894","subject":"[PATCH 2/3] Fix sed usage in tests to work around broken xpg4/sed on Solaris","startedAt":"2015-07-19T18:00:33Z","lastAt":"2015-07-19T21:49:33Z","messageCount":6,"participants":["Ben Walton","Johannes Sixt","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"266437","messageId":"1437328836-19156-1-git-send-email-bdwalton@gmail.com","threadId":"39894","inReplyTo":null,"subject":"Adapt some tests to work around broken Solaris tools","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2015-07-19T18:00:33Z","receivedAt":"2015-07-19T18:00:33Z","isPatch":false,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"This series is a respin of the previous submission, taking feedback\ninto account.\n"},{"id":"266438","messageId":"1437328836-19156-2-git-send-email-bdwalton@gmail.com","threadId":"39894","inReplyTo":"1437328836-19156-1-git-send-email-bdwalton@gmail.com","subject":"[PATCH 1/3] Modify tr expressions so that xpg4/tr handles it on Solaris","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2015-07-19T18:00:34Z","receivedAt":"2015-07-19T18:00:34Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"It seems that xpg4/tr mishandles some strings involving [ not followed\nby a character class:\n% echo '[::1]' | /usr/xpg4/bin/tr -d '[]'\n[::1\n\n% echo '[::1]' | /usr/xpg4/bin/tr -d '['\nusr/xpg4/bin/tr: Bad string.\n\nThis was breaking two tests. To fix the issue, use the octal\nrepresentations of [ and ] instead. Reference the octal expression as\na newly exported variable so that it's shared across tests and more\neasily understood when reading it.\n\nSigned-off-by: Ben Walton <bdwalton@gmail.com>\n---\n t/t5500-fetch-pack.sh | 2 +-\n t/t5601-clone.sh      | 8 ++++----\n t/test-lib.sh         | 5 ++++-\n 3 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex 3a9b775..2db9bde 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -547,7 +547,7 @@ check_prot_host_port_path () {\n \t\t*ssh*)\n \t\tpp=ssh\n \t\tuah=userandhost\n-\t\tehost=$(echo $3 | tr -d \"[]\")\n+\t\tehost=$(echo $3 | tr -d \"$squarebrackets\")\n \t\tdiagport=\"Diag: port=$4\"\n \t\t;;\n \t\t*)\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex bfdaf75..8299d14 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -445,7 +445,7 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '\n #IPv6\n for tuah in ::1 [::1] [::1]: user@::1 user@[::1] user@[::1]: [user@::1] [user@::1]:\n do\n-\tehost=$(echo $tuah | sed -e \"s/1]:/1]/ \"| tr -d \"[]\")\n+\tehost=$(echo $tuah | sed -e \"s/1]:/1]/ \" | tr -d \"$squarebrackets\")\n \ttest_expect_success \"clone ssh://$tuah/home/user/repo\" \"\n \t  test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo\n \t\"\n@@ -454,7 +454,7 @@ done\n #IPv6 from home directory\n for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]\n do\n-\teuah=$(echo $tuah | tr -d \"[]\")\n+\teuah=$(echo $tuah | tr -d \"$squarebrackets\")\n \ttest_expect_success \"clone ssh://$tuah/~repo\" \"\n \t  test_clone_url ssh://$tuah/~repo $euah '~repo'\n \t\"\n@@ -463,7 +463,7 @@ done\n #IPv6 with port number\n for tuah in [::1] user@[::1] [user@::1]\n do\n-\teuah=$(echo $tuah | tr -d \"[]\")\n+\teuah=$(echo $tuah | tr -d \"$squarebrackets\")\n \ttest_expect_success \"clone ssh://$tuah:22/home/user/repo\" \"\n \t  test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo\n \t\"\n@@ -472,7 +472,7 @@ done\n #IPv6 from home directory with port number\n for tuah in [::1] user@[::1] [user@::1]\n do\n-\teuah=$(echo $tuah | tr -d \"[]\")\n+\teuah=$(echo $tuah | tr -d \"$squarebrackets\")\n \ttest_expect_success \"clone ssh://$tuah:22/~repo\" \"\n \t  test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'\n \t\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 39da9c2..6b5b6cd 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -173,7 +173,10 @@ LF='\n # when case-folding filenames\n u200c=$(printf '\\342\\200\\214')\n \n-export _x05 _x40 _z40 LF u200c\n+# [ and ], for use by tr commands.\n+squarebrackets=\"\\133\\135\"\n+\n+export _x05 _x40 _z40 LF u200c squarebrackets\n \n # Each test should start with something like this, after copyright notices:\n #\n-- \n2.1.4\n"},{"id":"266436","messageId":"1437328836-19156-3-git-send-email-bdwalton@gmail.com","threadId":"39894","inReplyTo":"1437328836-19156-1-git-send-email-bdwalton@gmail.com","subject":"[PATCH 2/3] Fix sed usage in tests to work around broken xpg4/sed on Solaris","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2015-07-19T18:00:35Z","receivedAt":"2015-07-19T18:00:35Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The space following the last / in a sed command caused Solaris'\nxpg4/sed to fail, claiming the program was garbled and exit with\nstatus 2:\n\n% echo 'foo' | /usr/xpg4/bin/sed -e 's/foo/bar/ '\nsed: command garbled: s/foo/bar/\n% echo $?\n2\n\nFix this by simply removing the unnecessary space.\n\nSigned-off-by: Ben Walton <bdwalton@gmail.com>\n---\n t/t5601-clone.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 8299d14..8b7f8e1 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -445,7 +445,7 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '\n #IPv6\n for tuah in ::1 [::1] [::1]: user@::1 user@[::1] user@[::1]: [user@::1] [user@::1]:\n do\n-\tehost=$(echo $tuah | sed -e \"s/1]:/1]/ \" | tr -d \"$squarebrackets\")\n+\tehost=$(echo $tuah | sed -e \"s/1]:/1]/\" | tr -d \"$squarebrackets\")\n \ttest_expect_success \"clone ssh://$tuah/home/user/repo\" \"\n \t  test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo\n \t\"\n-- \n2.1.4\n"},{"id":"266439","messageId":"1437328836-19156-4-git-send-email-bdwalton@gmail.com","threadId":"39894","inReplyTo":"1437328836-19156-1-git-send-email-bdwalton@gmail.com","subject":"[PATCH 3/3] Fix sed usage in tests to work around broken xpg4/sed on Solaris","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2015-07-19T18:00:36Z","receivedAt":"2015-07-19T18:00:36Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"In 99094a7a, a trivial && breakage was fixed. This exposed a problem\nwith the test when run on Solaris with xpg4/sed that had gone silently\nundetected since its introduction in e4bd10b2. Solaris' sed executes\nthe requested substitution but prints a warning about the missing\nnewline at the end of the file and exits with status 2.\n\n% echo \"CHANGE_ME\" | \\\ntr -d \"\\\\012\" | /usr/xpg4/bin/sed -e 's/CHANGE_ME/change_me/'\nsed: Missing newline at end of file standard input.\nchange_me\n% echo $?\n2\n\nTo work around this, use perl to perform the substitution instead.\n\nSigned-off-by: Ben Walton <bdwalton@gmail.com>\n---\n t/t9500-gitweb-standalone-no-errors.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh\nindex e94b2f1..a7383fa 100755\n--- a/t/t9500-gitweb-standalone-no-errors.sh\n+++ b/t/t9500-gitweb-standalone-no-errors.sh\n@@ -290,7 +290,7 @@ test_expect_success 'setup incomplete lines' '\n \techo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n \tgit commit -a -m \"Add incomplete line\" &&\n \tgit tag incomplete_lines_add &&\n-\tsed -e s/CHANGE_ME/change_me/ <file >file+ &&\n+\tperl -pne \"s/CHANGE_ME/change_me/\" file >file+ &&\n \tmv -f file+ file &&\n \tgit commit -a -m \"Incomplete context line\" &&\n \tgit tag incomplete_lines_ctx &&\n-- \n2.1.4\n"},{"id":"266460","messageId":"55AC071B.9040800@kdbg.org","threadId":"39894","inReplyTo":"1437328836-19156-4-git-send-email-bdwalton@gmail.com","subject":"Re: [PATCH 3/3] Fix sed usage in tests to work around broken xpg4/sed on Solaris","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-07-19T20:22:51Z","receivedAt":"2015-07-19T20:22:51Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 19.07.2015 um 20:00 schrieb Ben Walton:\n> -\tsed -e s/CHANGE_ME/change_me/ <file >file+ &&\n> +\tperl -pne \"s/CHANGE_ME/change_me/\" file >file+ &&\n\nDid you mean '-lpe' or better '-pe' here?\n\n-- Hannes\n"},{"id":"266461","messageId":"CAPig+cSpTgcBA5YbfQWY+x+wc7rBQjugcan+MwLuZVcHaOH9kQ@mail.gmail.com","threadId":"39894","inReplyTo":"1437328836-19156-2-git-send-email-bdwalton@gmail.com","subject":"Re: [PATCH 1/3] Modify tr expressions so that xpg4/tr handles it on Solaris","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-07-19T21:49:33Z","receivedAt":"2015-07-19T21:49:33Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jul 19, 2015 at 2:00 PM, Ben Walton <bdwalton@gmail.com> wrote:\n> It seems that xpg4/tr mishandles some strings involving [ not followed\n> by a character class:\n> % echo '[::1]' | /usr/xpg4/bin/tr -d '[]'\n> [::1\n>\n> % echo '[::1]' | /usr/xpg4/bin/tr -d '['\n> usr/xpg4/bin/tr: Bad string.\n>\n> This was breaking two tests. To fix the issue, use the octal\n> representations of [ and ] instead. Reference the octal expression as\n> a newly exported variable so that it's shared across tests and more\n> easily understood when reading it.\n>\n> Signed-off-by: Ben Walton <bdwalton@gmail.com>\n> ---\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 39da9c2..6b5b6cd 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -173,7 +173,10 @@ LF='\n>  # when case-folding filenames\n>  u200c=$(printf '\\342\\200\\214')\n>\n> -export _x05 _x40 _z40 LF u200c\n> +# [ and ], for use by tr commands.\n> +squarebrackets=\"\\133\\135\"\n\nWhile it's true that the reader may be able to consult the commit\nmessage to learn more about \"squarebrackets\" and \"tr\", this might be\none of those cases where either a more explanatory in-code comment is\nwarranted or the comment should be dropped altogether, since the the\ncurrent comment is not illuminating. I'd vote for expanding the\ncomment a bit to mention \"some versions of Solaris 'tr'\" and a short\ndescription of the misbehavior.\n\nAlso, Hannes wondered how Solaris 'tr' would react to '[][]'. Were you\nable to test that or the alternative '[[]]'?\n"}]}