{"thread":{"id":"32404","subject":"[PATCH] t0200: \"locale\" may not exist","startedAt":"2012-12-19T06:47:03Z","lastAt":"2012-12-19T15:32:05Z","messageCount":4,"participants":["Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"205176","messageId":"7vlicubkt4.fsf@alter.siamese.dyndns.org","threadId":"32404","inReplyTo":null,"subject":"[PATCH] t0200: \"locale\" may not exist","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-19T06:47:03Z","receivedAt":"2012-12-19T06:47:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On systems without \"locale\" installed, t0200-gettext-basic.sh leaked\nerror messages when checking if some test locales are available.\nHide them, as they are not very useful.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/lib-gettext.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\nindex 0f76f6c..ae8883a 100644\n--- a/t/lib-gettext.sh\n+++ b/t/lib-gettext.sh\n@@ -14,12 +14,14 @@ export GIT_TEXTDOMAINDIR GIT_PO_PATH\n if test_have_prereq GETTEXT && ! test_have_prereq GETTEXT_POISON\n then\n \t# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian\n-\tis_IS_locale=$(locale -a | sed -n '/^is_IS\\.[uU][tT][fF]-*8$/{\n+\tis_IS_locale=$(locale -a 2>/dev/null |\n+\t\tsed -n '/^is_IS\\.[uU][tT][fF]-*8$/{\n \t\tp\n \t\tq\n \t}')\n \t# is_IS.ISO8859-1 on Solaris and FreeBSD, is_IS.iso88591 on Debian\n-\tis_IS_iso_locale=$(locale -a | sed -n '/^is_IS\\.[iI][sS][oO]8859-*1$/{\n+\tis_IS_iso_locale=$(locale -a 2>/dev/null |\n+\t\tsed -n '/^is_IS\\.[iI][sS][oO]8859-*1$/{\n \t\tp\n \t\tq\n \t}')\n-- \n1.8.1.rc2.196.g654d69e\n"},{"id":"205186","messageId":"20121219131822.GB7134@sigill.intra.peff.net","threadId":"32404","inReplyTo":"7vlicubkt4.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t0200: \"locale\" may not exist","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-12-19T13:18:22Z","receivedAt":"2012-12-19T13:18:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 18, 2012 at 10:47:03PM -0800, Junio C Hamano wrote:\n\n> On systems without \"locale\" installed, t0200-gettext-basic.sh leaked\n> error messages when checking if some test locales are available.\n> Hide them, as they are not very useful.\n\nObviously correct, though there is another way:\n\n> diff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\n> index 0f76f6c..ae8883a 100644\n> --- a/t/lib-gettext.sh\n> +++ b/t/lib-gettext.sh\n> @@ -14,12 +14,14 @@ export GIT_TEXTDOMAINDIR GIT_PO_PATH\n>  if test_have_prereq GETTEXT && ! test_have_prereq GETTEXT_POISON\n\nIf we turn this line into:\n\n  test_expect_success GETTEXT,!GETTEXT_POISON 'setup locale' '\n\nthen people can see the error output of the setup step in verbose mode.\n\nAnnoyingly, though, it means tweaking the quoting throughout the block\nto handle embedded single-quotes (if there is one feature I could take\nfrom perl back into shell, it would be arbitrary quote delimiters).\n\nPatch is below. I don't know if it is worth the complexity.\n\n-Peff\n\ndiff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\nindex 0f76f6c..d962c00 100644\n--- a/t/lib-gettext.sh\n+++ b/t/lib-gettext.sh\n@@ -11,18 +11,17 @@ then\n \n . \"$GIT_BUILD_DIR\"/git-sh-i18n\n \n-if test_have_prereq GETTEXT && ! test_have_prereq GETTEXT_POISON\n-then\n+test_expect_success GETTEXT,!GETTEXT_POISON 'setup locale' '\n \t# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian\n-\tis_IS_locale=$(locale -a | sed -n '/^is_IS\\.[uU][tT][fF]-*8$/{\n+\tis_IS_locale=$(locale -a | sed -n \"/^is_IS\\.[uU][tT][fF]-*8\\$/{\n \t\tp\n \t\tq\n-\t}')\n+\t}\")\n \t# is_IS.ISO8859-1 on Solaris and FreeBSD, is_IS.iso88591 on Debian\n-\tis_IS_iso_locale=$(locale -a | sed -n '/^is_IS\\.[iI][sS][oO]8859-*1$/{\n+\tis_IS_iso_locale=$(locale -a | sed -n \"/^is_IS\\.[iI][sS][oO]8859-*1\\$/{\n \t\tp\n \t\tq\n-\t}')\n+\t}\")\n \n \t# Export them as an environment variable so the t0202/test.pl Perl\n \t# test can use it too\n@@ -37,7 +36,7 @@ then\n \t\t# Exporting for t0202/test.pl\n \t\tGETTEXT_LOCALE=1\n \t\texport GETTEXT_LOCALE\n-\t\tsay \"# lib-gettext: Found '$is_IS_locale' as an is_IS UTF-8 locale\"\n+\t\tsay \"# lib-gettext: Found \\\"$is_IS_locale\\\" as an is_IS UTF-8 locale\"\n \telse\n \t\tsay \"# lib-gettext: No is_IS UTF-8 locale available\"\n \tfi\n@@ -48,8 +47,8 @@ then\n \t\t# Some of the tests need the reference Icelandic locale\n \t\ttest_set_prereq GETTEXT_ISO_LOCALE\n \n-\t\tsay \"# lib-gettext: Found '$is_IS_iso_locale' as an is_IS ISO-8859-1 locale\"\n+\t\tsay \"# lib-gettext: Found \\\"$is_IS_iso_locale\\\" as an is_IS ISO-8859-1 locale\"\n \telse\n \t\tsay \"# lib-gettext: No is_IS ISO-8859-1 locale available\"\n \tfi\n-fi\n+'\n"},{"id":"205191","messageId":"7vd2y6awo7.fsf@alter.siamese.dyndns.org","threadId":"32404","inReplyTo":"20121219131822.GB7134@sigill.intra.peff.net","subject":"Re: [PATCH] t0200: \"locale\" may not exist","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-19T15:28:24Z","receivedAt":"2012-12-19T15:28:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Dec 18, 2012 at 10:47:03PM -0800, Junio C Hamano wrote:\n>\n>> On systems without \"locale\" installed, t0200-gettext-basic.sh leaked\n>> error messages when checking if some test locales are available.\n>> Hide them, as they are not very useful.\n>\n> Obviously correct, though there is another way:\n>\n>> diff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\n>> index 0f76f6c..ae8883a 100644\n>> --- a/t/lib-gettext.sh\n>> +++ b/t/lib-gettext.sh\n>> @@ -14,12 +14,14 @@ export GIT_TEXTDOMAINDIR GIT_PO_PATH\n>>  if test_have_prereq GETTEXT && ! test_have_prereq GETTEXT_POISON\n>\n> If we turn this line into:\n>\n>   test_expect_success GETTEXT,!GETTEXT_POISON 'setup locale' '\n>\n> then people can see the error output of the setup step in verbose mode.\n\nOk, so it was not obviously \"correct\" after all ;-)\n\n> +test_expect_success GETTEXT,!GETTEXT_POISON 'setup locale' '\n>  \t# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian\n> -\tis_IS_locale=$(locale -a | sed -n '/^is_IS\\.[uU][tT][fF]-*8$/{\n> +\tis_IS_locale=$(locale -a | sed -n \"/^is_IS\\.[uU][tT][fF]-*8\\$/{\n\nDo we need to do this \\$?\n\n>  \t\tp\n>  \t\tq\n> -\t}')\n> +\t}\")\n>  \t# is_IS.ISO8859-1 on Solaris and FreeBSD, is_IS.iso88591 on Debian\n> -\tis_IS_iso_locale=$(locale -a | sed -n '/^is_IS\\.[iI][sS][oO]8859-*1$/{\n> +\tis_IS_iso_locale=$(locale -a | sed -n \"/^is_IS\\.[iI][sS][oO]8859-*1\\$/{\n>  \t\tp\n>  \t\tq\n> -\t}')\n> +\t}\")\n>  \n>  \t# Export them as an environment variable so the t0202/test.pl Perl\n>  \t# test can use it too\n> @@ -37,7 +36,7 @@ then\n>  \t\t# Exporting for t0202/test.pl\n>  \t\tGETTEXT_LOCALE=1\n>  \t\texport GETTEXT_LOCALE\n> -\t\tsay \"# lib-gettext: Found '$is_IS_locale' as an is_IS UTF-8 locale\"\n> +\t\tsay \"# lib-gettext: Found \\\"$is_IS_locale\\\" as an is_IS UTF-8 locale\"\n\n'\\''?\n"},{"id":"205192","messageId":"20121219153205.GA22207@sigill.intra.peff.net","threadId":"32404","inReplyTo":"7vd2y6awo7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t0200: \"locale\" may not exist","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-12-19T15:32:05Z","receivedAt":"2012-12-19T15:32:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 19, 2012 at 07:28:24AM -0800, Junio C Hamano wrote:\n\n> > +test_expect_success GETTEXT,!GETTEXT_POISON 'setup locale' '\n> >  \t# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian\n> > -\tis_IS_locale=$(locale -a | sed -n '/^is_IS\\.[uU][tT][fF]-*8$/{\n> > +\tis_IS_locale=$(locale -a | sed -n \"/^is_IS\\.[uU][tT][fF]-*8\\$/{\n> \n> Do we need to do this \\$?\n\nI'm not sure. Sane shells leave \"$/\" untouched, but I do not know if we\nneed to be conservative.\n\n> > -\t\tsay \"# lib-gettext: Found '$is_IS_locale' as an is_IS UTF-8 locale\"\n> > +\t\tsay \"# lib-gettext: Found \\\"$is_IS_locale\\\" as an is_IS UTF-8 locale\"\n> \n> '\\''?\n\nFine by me. I do not care either way in the output, and the escaped dq\nis marginally more readable in the source. But either way the source is\npretty ugly. :)\n\n-Peff\n"}]}