{"thread":{"id":"29383","subject":"[PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","startedAt":"2012-01-17T13:42:01Z","lastAt":"2012-01-24T20:13:14Z","messageCount":40,"participants":["Alex Riesen","Junio C Hamano","Ævar Arnfjörð Bjarmason","Jonathan Nieder","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"182684","messageId":"CALxABCZME-g++HxMsD4Nrn1J6s27vN7M_KQSVT3PeLWBqP7qJg@mail.gmail.com","threadId":"29383","inReplyTo":null,"subject":"[PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-17T13:42:01Z","receivedAt":"2012-01-17T13:42:01Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\nIt is very unexpected.\n\n---\n\nI usually disable i18n on my working systems as they are generally very\nout-of-date and not supported by any sane developer. In particular the\ngettext provided with this (very old) Cygwin distribution is fubar and\nnever produces any output.\n\n Makefile       |    1 +\n git-sh-i18n.sh |    4 ++--\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a782409..d82ea6a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1887,6 +1887,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n+    -e 's/@@NO_GETTEXT@@/$(NO_GETTEXT)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\n     $@.sh >$@+\n endef\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..7f7e32b 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -18,7 +18,7 @@ export TEXTDOMAINDIR\n\n if test -z \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh\n>/dev/null 2>&1\n+\tif test -z \"@@NO_GETTEXT@@\" && test -z\n\"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null\n2>&1\n \tthen\n \t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n \t\t# else than setting up the environment and loading gettext.sh\n@@ -29,7 +29,7 @@ then\n \t\t# can't.\n \t\t. gettext.sh\n\n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test\n\"$(gettext -h 2>&1)\" = \"-h\"\n+\telif test -z \"@@NO_GETTEXT@@\" && test -z\n\"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" =\n\"-h\"\n \tthen\n \t\t# We don't have gettext.sh, but there's a gettext binary in our\n \t\t# path. This is probably Solaris or something like it which has a\n-- \n1.7.8.2.388.ge40c2\n\n\nFrom 36e73fe14cbecd04512a6e8a21b9eb14d278d1dc Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa.lkml@gmail.com>\nDate: Tue, 17 Jan 2012 14:25:24 +0100\nSubject: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined\n\nOtherwise the i18n is used in the scripts even with NO_GETTEXT set.\nIt is very unexpected.\n\nI generally disable i18n on my working systems as they are generally very\nout-of-date and not supported by any sane developer. In particular the\ngettext provided with this (very old) Cygwin distribution is fubar and\nnever produces any output.\n---\n Makefile       |    1 +\n git-sh-i18n.sh |    4 ++--\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a782409..d82ea6a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1887,6 +1887,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n+    -e 's/@@NO_GETTEXT@@/$(NO_GETTEXT)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\n     $@.sh >$@+\n endef\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..7f7e32b 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -18,7 +18,7 @@ export TEXTDOMAINDIR\n \n if test -z \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n+\tif test -z \"@@NO_GETTEXT@@\" && test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n \tthen\n \t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n \t\t# else than setting up the environment and loading gettext.sh\n@@ -29,7 +29,7 @@ then\n \t\t# can't.\n \t\t. gettext.sh\n \n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n+\telif test -z \"@@NO_GETTEXT@@\" && test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n \tthen\n \t\t# We don't have gettext.sh, but there's a gettext binary in our\n \t\t# path. This is probably Solaris or something like it which has a\n-- \n1.7.8.2.388.ge40c2\n\n"},{"id":"182689","messageId":"7vfwfervt9.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CALxABCZME-g++HxMsD4Nrn1J6s27vN7M_KQSVT3PeLWBqP7qJg@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-17T19:08:34Z","receivedAt":"2012-01-17T19:08:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> From: Alex Riesen <raa.lkml@gmail.com>\n> Date: Tue, 17 Jan 2012 14:25:24 +0100\n> Subject: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined\n>\n> Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n> It is very unexpected.\n>\n> I generally disable i18n on my working systems as they are generally very\n> out-of-date and not supported by any sane developer. In particular the\n> gettext provided with this (very old) Cygwin distribution is fubar and\n> never produces any output.\n> ---\n\nThanks for spotting. I agree that we should honor NO_GETTEXT here.\n\nBut the result of the patch looks almost unreadable. could we restructure\nthe script like this instead?\n\n        # Decide what to do...\n        GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n\tif test -n \"@@NO_GETTEXT@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n\tthen\n\t\t: no probing necessary\n        elif test -n \"$GIT_GETTEXT_POISON\"\n        then\n                GIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n        elif type gettext.sh >/dev/null 2>&1\n        then\n                GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n        elif test \"$(gettext -h 2>&1)\" = \"-h\"\n        then\n                GIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n        fi\n        export GIT_INTERNAL_GETTEXT_SH_SCHEME\n\n        # ... and then carry out the decision\n        case \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" in\n        gnu)\n                ... gnu definition here ...\n                ;;\n        solaris)\n                ... solaris cdefinition here ...\n                ;;\n        poison)\n                ... poison cdefinition here ...\n                ;;\n        *)\n                ... fallthru definition here ...\n                ;;\n        esac\n"},{"id":"182725","messageId":"CALxABCYXWxp=wVahbPjt9V4n5P7EQnqFFT3S5Dc7Co-P9BGJFQ@mail.gmail.com","threadId":"29383","inReplyTo":"7vfwfervt9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-18T14:25:54Z","receivedAt":"2012-01-18T14:25:54Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Jan 17, 2012 at 20:08, Junio C Hamano <gitster@pobox.com> wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n> Thanks for spotting. I agree that we should honor NO_GETTEXT here.\n>\n> But the result of the patch looks almost unreadable. could we restructure\n> the script like this instead?\n>\n>        # Decide what to do...\n>        GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n>        if test -n \"@@NO_GETTEXT@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n>        then\n\nOh, it is much nicer indeed. I shall redo the patch as soon as I get off\nthis crappy winxp computer.\n"},{"id":"182727","messageId":"CACBZZX4TsL-tj04PmUwGNWjXO+JY-8unAv-aRKOGvgB71qdYCg@mail.gmail.com","threadId":"29383","inReplyTo":"CALxABCZME-g++HxMsD4Nrn1J6s27vN7M_KQSVT3PeLWBqP7qJg@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-01-18T15:22:23Z","receivedAt":"2012-01-18T15:22:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Jan 17, 2012 at 14:42, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n> It is very unexpected.\n\nSo the reason it's like that is that I was assuming that gettext.sh\nwouldn't be FUBAR anywhere, but the translations shouldn't kick in\nsince we haven't installed them during \"make install\".\n\nBut I wonder if this negatively affects some systems, now we now:\n\n * Don't use gettext.sh, which means that we're using our fallback\n   shell function instead of the binary gettext(1), which is probably\n   faster.\n\n * Use our own eval_gettext() instead of using the system one, which\n   uses the GNU binary which is more likely to be in the FS cache\n   already since other programs are probably using it.\n\nWhich is why I didn't do something like this to begin with.\n"},{"id":"182734","messageId":"CALxABCadHdvR02Br9e6STy0w+EPoycUKr62RiSUSP_EPF-TH3g@mail.gmail.com","threadId":"29383","inReplyTo":"CACBZZX4TsL-tj04PmUwGNWjXO+JY-8unAv-aRKOGvgB71qdYCg@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-18T18:57:18Z","receivedAt":"2012-01-18T18:57:18Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Wed, Jan 18, 2012 at 16:22, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> On Tue, Jan 17, 2012 at 14:42, Alex Riesen <raa.lkml@gmail.com> wrote:\n>> Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n>> It is very unexpected.\n>\n> So the reason it's like that is that I was assuming that gettext.sh\n> wouldn't be FUBAR anywhere, but the translations shouldn't kick in\n> since we haven't installed them during \"make install\".\n>\n> But I wonder if this negatively affects some systems, now we now:\n>\n>  * Don't use gettext.sh, which means that we're using our fallback\n>   shell function instead of the binary gettext(1), which is probably\n>   faster.\n>\n>  * Use our own eval_gettext() instead of using the system one, which\n>   uses the GNU binary which is more likely to be in the FS cache\n>   already since other programs are probably using it.\n>\n> Which is why I didn't do something like this to begin with.\n\nWell, if I say NO_GETTEXT, I kind of want none of local gettext,\nwhether it works, or not.\n"},{"id":"182736","messageId":"20120118195438.GA18892@blimp.dmz","threadId":"29383","inReplyTo":"7vfwfervt9.fsf@alter.siamese.dyndns.org","subject":"[PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-18T19:54:38Z","receivedAt":"2012-01-18T19:54:38Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\nIt is very unexpected.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n\n---\n\nJunio C Hamano, Tue, Jan 17, 2012 20:08:34 +0100:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n> > Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n> > It is very unexpected.\n> >\n...\n> \n> But the result of the patch looks almost unreadable. could we restructure\n> the script like this instead?\n> ...\n\nDone. I simplified the commentary on \"poison\" a little.\n\n Makefile       |    1 +\n git-sh-i18n.sh |  102 +++++++++++++++++++++++++++-----------------------------\n 2 files changed, 50 insertions(+), 53 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a782409..d82ea6a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1887,6 +1887,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n+    -e 's/@@NO_GETTEXT@@/$(NO_GETTEXT)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\n     $@.sh >$@+\n endef\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..1902fb1 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -16,61 +16,44 @@ else\n fi\n export TEXTDOMAINDIR\n \n-if test -z \"$GIT_GETTEXT_POISON\"\n+GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n+if test -n \"@@NO_GETTEXT@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n+then\n+\t: no probing necessary\n+elif test -n \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n-\tthen\n-\t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n-\t\t# else than setting up the environment and loading gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Try to use libintl's gettext.sh, or fall back to English if we\n-\t\t# can't.\n-\t\t. gettext.sh\n-\n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n-\tthen\n-\t\t# We don't have gettext.sh, but there's a gettext binary in our\n-\t\t# path. This is probably Solaris or something like it which has a\n-\t\t# gettext implementation that isn't GNU libintl.\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Solaris has a gettext(1) but no eval_gettext(1)\n-\t\teval_gettext () {\n-\t\t\tgettext \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\n-\telse\n-\t\t# Since gettext.sh isn't available we'll have to define our own\n-\t\t# dummy pass-through functions.\n-\n-\t\t# Tell our tests that we don't have the real gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\tgettext () {\n-\t\t\tprintf \"%s\" \"$1\"\n-\t\t}\n-\n-\t\teval_gettext () {\n-\t\t\tprintf \"%s\" \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\tfi\n-else\n-\t# Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests\n-\t# this relies on an environment variable\n-\n \tGIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n-\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n+elif test -n type gettext.sh >/dev/null 2>&1\n+then\n+\t# This is GNU libintl's gettext.sh, we don't need to do anything\n+\t# else than setting up the environment and loading gettext.sh\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n+elif test \"$(gettext -h 2>&1)\" = \"-h\"\n+then\n+\t# We don't have gettext.sh, but there's a gettext binary in our\n+\t# path. This is probably Solaris or something like it which has a\n+\t# gettext implementation that isn't GNU libintl.\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n+fi\n+export GIT_INTERNAL_GETTEXT_SH_SCHEME\n \n+case \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" in\n+gnu)\n+\t# Try to use libintl's gettext.sh, or fall back to English if we\n+\t# can't.\n+\t. gettext.sh\n+\t;;\n+solaris)\n+\t# Solaris has a gettext(1) but no eval_gettext(1)\n+\teval_gettext () {\n+\t\tgettext \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+poison)\n+\t# Used in tests\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n@@ -78,7 +61,20 @@ else\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n-fi\n+\t;;\n+*)\n+\tgettext () {\n+\t\tprintf \"%s\" \"$1\"\n+\t}\n+\n+\teval_gettext () {\n+\t\tprintf \"%s\" \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+esac\n \n # Git-specific wrapper functions\n gettextln () {\n-- \n1.7.9.rc0.84.g0aa6c\n"},{"id":"182754","messageId":"CACBZZX4tB6DGV-1tiuOamq7ACPk0a-=1Pb9Vk1SgyDqAq-EFOw@mail.gmail.com","threadId":"29383","inReplyTo":"CALxABCadHdvR02Br9e6STy0w+EPoycUKr62RiSUSP_EPF-TH3g@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-01-18T23:18:54Z","receivedAt":"2012-01-18T23:18:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Jan 18, 2012 at 19:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On Wed, Jan 18, 2012 at 16:22, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>> On Tue, Jan 17, 2012 at 14:42, Alex Riesen <raa.lkml@gmail.com> wrote:\n>>> Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n>>> It is very unexpected.\n>>\n>> So the reason it's like that is that I was assuming that gettext.sh\n>> wouldn't be FUBAR anywhere, but the translations shouldn't kick in\n>> since we haven't installed them during \"make install\".\n>>\n>> But I wonder if this negatively affects some systems, now we now:\n>>\n>>  * Don't use gettext.sh, which means that we're using our fallback\n>>   shell function instead of the binary gettext(1), which is probably\n>>   faster.\n>>\n>>  * Use our own eval_gettext() instead of using the system one, which\n>>   uses the GNU binary which is more likely to be in the FS cache\n>>   already since other programs are probably using it.\n>>\n>> Which is why I didn't do something like this to begin with.\n>\n> Well, if I say NO_GETTEXT, I kind of want none of local gettext,\n> whether it works, or not.\n\nThat's not what NO_GETTEXT means, and not what it *should* mean. It\nmeans that your output won't be translated, but we might still make\nuse of a locally installed library to provide the gettext() and\neval_gettext() functions.\n\nThis approach has worked everywhere so far (Linux, OSX, *BSD etc.),\nand you want to change *everywhere* because you have some completely\nbroken Cygwin install.\n\nHow did you even get that install? Is it a known issue? Some ancient\nnow-fixed bug? What version of Cygwin / gettext etc.\n\nNow I'm not saying that we shouldn't fix this, I just don't think that\nthis is the right way to go about it.\n\nNow I haven't done exhaustive tests but this is the sort of slowdown\nwe might be looking at on Linux for output, both with warm cache:\n\n    $ cat our-eval_gettext.sh\n    #!/bin/bash\n\n    eval_gettext () {\n            printf \"%s\" \"$1\" | (\n                    export PATH $(git sh-i18n--envsubst --variables \"$1\");\n                    git sh-i18n--envsubst \"$1\"\n            )\n    }\n    for i in {1..1000}\n    do\n        some_variable=\"for speed\"\n        eval_gettext \"benchmark this \\$some_variable\"\n    done\n    $ time bash our-eval_gettext.sh >/dev/null\n\n    real    0m3.336s\n    user    0m0.052s\n    sys     0m0.128s\n\nCompared to using the system eval_gettext, which for me is much\nfaster:\n\n    $ cat system-eval_gettext.sh\n    #!/bin/bash\n\n    . gettext.sh\n    for i in {1..1000}\n    do\n        some_variable=\"for speed\"\n        eval_gettext \"benchmark this \\$some_variable\"\n    done\n    $ time bash system-eval_gettext.sh >/dev/null\n\n    real    0m1.671s\n    user    0m0.048s\n    sys     0m0.140s\n\nAnd then we have the gettext() function itself:\n\n    $ cat our-gettext.sh\n    #!/bin/bash\n\n    gettext () {\n            printf \"%s\" \"$1\"\n    }\n\n    for i in {1..1000}\n    do\n        gettext \"benchmark this\"\n    done\n    $ cat system-gettext.sh\n    #!/bin/bash\n\n    for i in {1..1000}\n    do\n        gettext \"benchmark this\"\n    done\n\nWhere our fallback is faster, because printf() is a bash built-in:\n\n    $ time bash system-gettext.sh >/dev/null\n\n    real    0m0.534s\n    user    0m0.016s\n    sys     0m0.084s\n    $ time bash our-gettext.sh >/dev/null\n\n    real    0m0.018s\n    user    0m0.016s\n    sys     0m0.000s\n\nAnyway speed is the least of the issues here, it's not like we're very\nconstrained by spewing out gettext output.\n\nI just think we should consider portability more carefully than \"it\ndoesn't work on one obscure setup, let's change it everywhere\", when\nactually it's working just fine in most places.\n\nI think a better fix would be to add probes for whether the system\nfunctions actually work in the autoconf script.\n\nI'd also love to be able to use C macros in the git-*.sh scripts, it\nwould make the code in git-sh-i18n.sh much nicer since we can\ndetermine what functions we want at compile time.\n\nAnother option would be to pipe our shellscripts through some\npre-processor that would completely remove the gettext and\neval_gettext calls. Then we'd be doing the same thing we're doing on\nthe C-Level, and we wouldn't have the previously cited command-call\noverhead or Win32.\n\nBut in summary: We shouldn't be *always* using fallback functions\nwhether they're the C stuff in compat/* or the gettext fallbacks in\ngit-sh-i18n.sh just because there's some version out there of the\nsystem-supplied functions that's broken.\n\nIt makes sense to prefer the system functions by default in both\ncases, but when the OS one can be broken or lacking we can just add\nprobes or Makefile options like we do for fnmatch() with the\nNO_FNMATCH_CASEFOLD switch.\n"},{"id":"182755","messageId":"20120119001225.GA13975@burratino","threadId":"29383","inReplyTo":"20120118195438.GA18892@blimp.dmz","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-19T00:12:25Z","receivedAt":"2012-01-19T00:12:25Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nAlex Riesen wrote:\n\n> [Subject: i18n: disable i18n for shell scripts if NO_GETTEXT define]\n>\n> Otherwise the i18n is used in the scripts even with NO_GETTEXT set.\n> It is very unexpected.\n\nSounds like a good idea.  Quick comments:\n\n[...]\n> --- a/git-sh-i18n.sh\n> +++ b/git-sh-i18n.sh\n> @@ -16,61 +16,44 @@ else\n>  fi\n>  export TEXTDOMAINDIR\n>  \n> -if test -z \"$GIT_GETTEXT_POISON\"\n> +GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n> +if test -n \"@@NO_GETTEXT@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n> +then\n> +\t: no probing necessary\n> +elif test -n \"$GIT_GETTEXT_POISON\"\n>  then\n> -\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n> -\tthen\n> +elif test -n type gettext.sh >/dev/null 2>&1\n> +then\n\nI like the unindenting.  Alas, I get\n\n\t1: test: type: unexpected operator\n\nI suspect this should just say \"elif type gettext.sh >/dev/null 2>&1\".\n\nThe rest looks good.  Thanks for writing it.\n"},{"id":"182756","messageId":"20120119001548.GA13926@burratino","threadId":"29383","inReplyTo":"CACBZZX4tB6DGV-1tiuOamq7ACPk0a-=1Pb9Vk1SgyDqAq-EFOw@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-19T00:15:48Z","receivedAt":"2012-01-19T00:15:48Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n\n> That's not what NO_GETTEXT means, and not what it *should* mean. It\n> means that your output won't be translated, but we might still make\n> use of a locally installed library to provide the gettext() and\n> eval_gettext() functions.\n>\n> This approach has worked everywhere so far (Linux, OSX, *BSD etc.),\n> and you want to change *everywhere* because you have some completely\n> broken Cygwin install.\n\nI thought NO_GETTEXT meant either \"I'm aware that there is this new\ntranslation feature, and it may or may not be useful to me some day,\nbut no thanks for now, since I cannot tolerate the possibility of\nregressions\" (i.e., opting out of a new feature) or \"my platform does\nnot have suitable gettext infrastructure so please do not use it\"\n(i.e., reducing build-time dependencies by making some optional).\n\n\"I don't want localized messages\" is spelled as \"LC_MESSAGES=C; export\nLC_MESSAGES\", not as \"make NO_GETTEXT=YesPlease\".\n\nI guess I am wondering, does the approach in Alex's patch have the\npotential to cause actual problems?  If it doesn't, I don't see what\nthere is to complain about.\n\nHope that helps,\nJonathan\n"},{"id":"182757","messageId":"7vfwfclf4v.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CACBZZX4tB6DGV-1tiuOamq7ACPk0a-=1Pb9Vk1SgyDqAq-EFOw@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-19T00:17:36Z","receivedAt":"2012-01-19T00:17:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Wed, Jan 18, 2012 at 19:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n> ...\n>> Well, if I say NO_GETTEXT, I kind of want none of local gettext,\n>> whether it works, or not.\n>\n> That's not what NO_GETTEXT means, and not what it *should* mean. It\n> means that your output won't be translated, but we might still make\n> use of a locally installed library to provide the gettext() and\n> eval_gettext() functions.\n\nYou are right.\n\nIn the current approach we take for shell scripts, we cannot have \"No i18n\nwhatsoever and messages are emit with printf and echo\". We always have to\ngo through gettext/eval_gettext even though they may be an implementation\nthat does not do i18n at all.\n\n> Now I haven't done exhaustive tests but this is the sort of slowdown\n> we might be looking at on Linux for output,...\n\nI think we judged that it is OK not to worry about the performance of\nmessage generation, back when we decided to take the current approach.\n\n> Anyway speed is the least of the issues here, it's not like we're very\n> constrained by spewing out gettext output.\n>\n> I just think we should consider portability more carefully than \"it\n> doesn't work on one obscure setup, let's change it everywhere\", when\n> actually it's working just fine in most places.\n> ...\n> But in summary: We shouldn't be *always* using fallback functions\n> whether they're the C stuff in compat/* or the gettext fallbacks in\n> git-sh-i18n.sh just because there's some version out there of the\n> system-supplied functions that's broken.\n> \n> It makes sense to prefer the system functions by default in both\n> cases, but when the OS one can be broken or lacking we can just add\n> probes or Makefile options like we do for fnmatch() with the\n> NO_FNMATCH_CASEFOLD switch.\n\nSo we need \"MY_GETTEXT_IS_BROKEN\" to decline the use of system gettext\nin addition to \"NO_GETTEXT\" to ask Git not to translate the messages. Is\nthat correct?\n\nIf that is the case, should we do something like\n\n\tLANG=C LC_ALL=C\n        export LANG LC_ALL\n\nin our shell scripts, when building for NO_GETTEXT target?\n"},{"id":"182766","messageId":"4F17C294.6010004@viscovery.net","threadId":"29383","inReplyTo":"7vfwfclf4v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-01-19T07:13:24Z","receivedAt":"2012-01-19T07:13:24Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 1/19/2012 1:17, schrieb Junio C Hamano:\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n> \n>> On Wed, Jan 18, 2012 at 19:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n>> ...\n>>> Well, if I say NO_GETTEXT, I kind of want none of local gettext,\n>>> whether it works, or not.\n>>\n>> That's not what NO_GETTEXT means, and not what it *should* mean. It\n>> means that your output won't be translated, but we might still make\n>> use of a locally installed library to provide the gettext() and\n>> eval_gettext() functions.\n> \n> You are right.\n\nSorry to disagree: We have, e.g., NO_MMAP, and I can set it to request\nthat some alternative is used, even if I have a working mmap(). The option\nname \"NO_GETTEXT\" is in exactly the same spirit.\n\n> In the current approach we take for shell scripts, we cannot have \"No i18n\n> whatsoever and messages are emit with printf and echo\". We always have to\n> go through gettext/eval_gettext even though they may be an implementation\n> that does not do i18n at all.\n\nJust like we go through _() in C code, even though there may be an\nimplementation that does not do i18n at all, right?\n\ngettext/eval_gettext annotations are the shell equivalent of _()\nannotations in C code, aren't they? Neither go away just by defining\nNO_GETTEXT. It is just a quality-of-implementation issue that those\nannotations have as little overhead as possible if NO_GETTEXT is defined.\nIn C, it is easy, in shell code it may be more involved.\n\n-- Hannes\n"},{"id":"182771","messageId":"CALxABCbaBmP6k5TYrYLCYm8oiv=9cF=N7_opSTKUnbkz5b-cwg@mail.gmail.com","threadId":"29383","inReplyTo":"CACBZZX4tB6DGV-1tiuOamq7ACPk0a-=1Pb9Vk1SgyDqAq-EFOw@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-19T09:13:20Z","receivedAt":"2012-01-19T09:13:20Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Thu, Jan 19, 2012 at 00:18, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> On Wed, Jan 18, 2012 at 19:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n>>\n>> Well, if I say NO_GETTEXT, I kind of want none of local gettext,\n>> whether it works, or not.\n>\n> That's not what NO_GETTEXT means, and not what it *should* mean. It\n> means that your output won't be translated, but we might still make\n> use of a locally installed library to provide the gettext() and\n> eval_gettext() functions.\n\nI would never guess all that by its name: NO_GETTEXT. I wanted to\nsay: there is no gettext in this installation, don't even try it.\n\n> This approach has worked everywhere so far (Linux, OSX, *BSD etc.),\n> and you want to change *everywhere* because you have some completely\n> broken Cygwin install.\n\nJust as I said.\n\n> How did you even get that install? Is it a known issue? Some ancient\n> now-fixed bug?\n\nIt is very likely. Or probably just a one installation problem: the\nproblem is not consistently everywhere here. Some installations\nwork (if slow).\n\n> What version of Cygwin / gettext etc.\n\nNo idea. The person or persons who did this to me have no idea either.\n\n> Now I'm not saying that we shouldn't fix this, I just don't think that\n> this is the right way to go about it.\n\nAnd I agree.\n\n> But in summary: We shouldn't be *always* using fallback functions\n> whether they're the C stuff in compat/* or the gettext fallbacks in\n> git-sh-i18n.sh just because there's some version out there of the\n> system-supplied functions that's broken.\n>\n> It makes sense to prefer the system functions by default in both\n> cases, but when the OS one can be broken or lacking we can just add\n> probes or Makefile options like we do for fnmatch() with the\n> NO_FNMATCH_CASEFOLD switch.\n\nYes, and I personally shall welcome a chance to insult the local IT\nby suggesting BROKEN_SH_GETTEXT. Not that they get the point...\n"},{"id":"182772","messageId":"CALxABCa6cxxnxzSQuo5HNGBCax5VGrX7YGiBmkHw_1B5Xm1ASA@mail.gmail.com","threadId":"29383","inReplyTo":"20120119001225.GA13975@burratino","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-19T09:15:23Z","receivedAt":"2012-01-19T09:15:23Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Thu, Jan 19, 2012 at 01:12, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> I like the unindenting.  Alas, I get\n>\n>        1: test: type: unexpected operator\n>\n> I suspect this should just say \"elif type gettext.sh >/dev/null 2>&1\".\n\nIndeed. Copy-paste error. I wonder why I didn't notice it...\nYes, ran the tests, both with and without NO_GETTEXT.\n\n> The rest looks good.  Thanks for writing it.\n\nWas Junios idea, I just liked it.\n"},{"id":"182773","messageId":"CALxABCZsKHbLCwv0SKGt_M_GoTJ5eQZ3feUR-Ho4hW_TQuoFgg@mail.gmail.com","threadId":"29383","inReplyTo":"7vfwfclf4v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-19T09:24:35Z","receivedAt":"2012-01-19T09:24:35Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Thu, Jan 19, 2012 at 01:17, Junio C Hamano <gitster@pobox.com> wrote:\n> So we need \"MY_GETTEXT_IS_BROKEN\" to decline the use of system gettext\n> in addition to \"NO_GETTEXT\" to ask Git not to translate the messages. Is\n> that correct?\n\nI think yes.\n\n> If that is the case, should we do something like\n>\n>        LANG=C LC_ALL=C\n>        export LANG LC_ALL\n>\n> in our shell scripts, when building for NO_GETTEXT target?\n\nJust for the record: gettext here stays broken with LANG and LC_ALL set to C.\nBut the locale-dependent formatting in C functions will change. Wont be a\nproblem here, though. The named formatting is broken, too: strftime, for\ninstance, always formats in C locale.\n"},{"id":"182798","messageId":"7vhazrk0jx.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"4F17C294.6010004@viscovery.net","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-19T18:30:10Z","receivedAt":"2012-01-19T18:30:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> ... We have, e.g., NO_MMAP, and I can set it to request\n> that some alternative is used, even if I have a working mmap(). The option\n> name \"NO_GETTEXT\" is in exactly the same spirit.\n>\n>> In the current approach we take for shell scripts, we cannot have \"No i18n\n>> whatsoever and messages are emit with printf and echo\". We always have to\n>> go through gettext/eval_gettext even though they may be an implementation\n>> that does not do i18n at all.\n>\n> Just like we go through _() in C code, even though there may be an\n> implementation that does not do i18n at all, right?\n\nYes, just like that. The small detail that _() can be #define'd out to\nempty while gettext/eval_gettext cannot be made to be no-impact like that\ndoes not really matter.\n\n> In C, it is easy, in shell code it may be more involved.\n\nCorrect.\n"},{"id":"182802","messageId":"20120119195222.GA5011@blimp.dmz","threadId":"29383","inReplyTo":"CALxABCbaBmP6k5TYrYLCYm8oiv=9cF=N7_opSTKUnbkz5b-cwg@mail.gmail.com","subject":"[PATCH] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-19T19:52:22Z","receivedAt":"2012-01-19T19:52:22Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Some systems have gettext.sh (GNU gettext) installed, but it is either broken\nor misconfigured in such a way so its output is not usable.\nFor instance, on this particular system, a Cygwin installations gettext\nproduces no output whatsoever.\n\nIn case the users of these systems are unable or not interested in fixing\nthem, setting the new Makefile switch should help:\n\n    USE_FALLTHROUGH_GETTEXT_SCHEME=yes\n\nThis will replace the translation routines with fallthrough versions, which\ncurrently used only for regression testing.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nAlex Riesen, Thu, Jan 19, 2012 10:13:20 +0100:\n> On Thu, Jan 19, 2012 at 00:18, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> > It makes sense to prefer the system functions by default in both\n> > cases, but when the OS one can be broken or lacking we can just add\n> > probes or Makefile options like we do for fnmatch() with the\n> > NO_FNMATCH_CASEFOLD switch.\n> \n> Yes, and I personally shall welcome a chance to insult the local IT\n> by suggesting BROKEN_SH_GETTEXT. Not that they get the point...\n\nI believe this patch does just that. It is certainly enough for my purposes.\nThe copy-paste error noticed by Jonathan is also fixed, thanks!\nI didn't add the tracking of the switch in GIT-BUILD-OPTIONS: didn't found\nhow to do it quickly enough in this time of evening, and gave up, thinking\nthat no one sane would need to set the option anyway. So at the moment a\n\"make clean\" needed when changing it.\n\n Makefile       |    4 ++\n git-sh-i18n.sh |  102 +++++++++++++++++++++++++++-----------------------------\n 2 files changed, 53 insertions(+), 53 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a782409..806d126 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -47,6 +47,9 @@ all::\n # A translated Git requires GNU libintl or another gettext implementation,\n # plus libintl-perl at runtime.\n #\n+# Define USE_FALLTHROUGH_GETTEXT_SCHEME, if you don't want to trust the\n+# installed gettext translation of the shell scripts output.\n+#\n # Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't\n # trust the langinfo.h's nl_langinfo(CODESET) function to return the\n # current character set. GNU and Solaris have a nl_langinfo(CODESET),\n@@ -1887,6 +1890,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n+    -e 's/@@USE_FALLTHROUGH_GETTEXT_SCHEME@@/$(USE_FALLTHROUGH_GETTEXT_SCHEME)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\n     $@.sh >$@+\n endef\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..da8b214 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -16,61 +16,44 @@ else\n fi\n export TEXTDOMAINDIR\n \n-if test -z \"$GIT_GETTEXT_POISON\"\n+GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n+if test -n \"@@USE_FALLTHROUGH_GETTEXT_SCHEME@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n+then\n+\t: no probing necessary\n+elif test -n \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n-\tthen\n-\t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n-\t\t# else than setting up the environment and loading gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Try to use libintl's gettext.sh, or fall back to English if we\n-\t\t# can't.\n-\t\t. gettext.sh\n-\n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n-\tthen\n-\t\t# We don't have gettext.sh, but there's a gettext binary in our\n-\t\t# path. This is probably Solaris or something like it which has a\n-\t\t# gettext implementation that isn't GNU libintl.\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Solaris has a gettext(1) but no eval_gettext(1)\n-\t\teval_gettext () {\n-\t\t\tgettext \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\n-\telse\n-\t\t# Since gettext.sh isn't available we'll have to define our own\n-\t\t# dummy pass-through functions.\n-\n-\t\t# Tell our tests that we don't have the real gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\tgettext () {\n-\t\t\tprintf \"%s\" \"$1\"\n-\t\t}\n-\n-\t\teval_gettext () {\n-\t\t\tprintf \"%s\" \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\tfi\n-else\n-\t# Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests\n-\t# this relies on an environment variable\n-\n \tGIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n-\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n+elif type gettext.sh >/dev/null 2>&1\n+then\n+\t# This is GNU libintl's gettext.sh, we don't need to do anything\n+\t# else than setting up the environment and loading gettext.sh\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n+elif test \"$(gettext -h 2>&1)\" = \"-h\"\n+then\n+\t# We don't have gettext.sh, but there's a gettext binary in our\n+\t# path. This is probably Solaris or something like it which has a\n+\t# gettext implementation that isn't GNU libintl.\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n+fi\n+export GIT_INTERNAL_GETTEXT_SH_SCHEME\n \n+case \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" in\n+gnu)\n+\t# Try to use libintl's gettext.sh, or fall back to English if we\n+\t# can't.\n+\t. gettext.sh\n+\t;;\n+solaris)\n+\t# Solaris has a gettext(1) but no eval_gettext(1)\n+\teval_gettext () {\n+\t\tgettext \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+poison)\n+\t# Used in tests\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n@@ -78,7 +61,20 @@ else\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n-fi\n+\t;;\n+*)\n+\tgettext () {\n+\t\tprintf \"%s\" \"$1\"\n+\t}\n+\n+\teval_gettext () {\n+\t\tprintf \"%s\" \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+esac\n \n # Git-specific wrapper functions\n gettextln () {\n-- \n1.7.9.rc1.92.ga90a1\n"},{"id":"182847","messageId":"CACBZZX7iiF2um11FvD+MBz=rZb7RrHtCJp3PqexLnSp3-Cbqug@mail.gmail.com","threadId":"29383","inReplyTo":"7vhazrk0jx.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-01-20T09:50:23Z","receivedAt":"2012-01-20T09:50:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Jan 19, 2012 at 19:30, Junio C Hamano <gitster@pobox.com> wrote:\n> Johannes Sixt <j.sixt@viscovery.net> writes:\n>\n>> ... We have, e.g., NO_MMAP, and I can set it to request\n>> that some alternative is used, even if I have a working mmap(). The option\n>> name \"NO_GETTEXT\" is in exactly the same spirit.\n>>\n>>> In the current approach we take for shell scripts, we cannot have \"No i18n\n>>> whatsoever and messages are emit with printf and echo\". We always have to\n>>> go through gettext/eval_gettext even though they may be an implementation\n>>> that does not do i18n at all.\n>>\n>> Just like we go through _() in C code, even though there may be an\n>> implementation that does not do i18n at all, right?\n>\n> Yes, just like that. The small detail that _() can be #define'd out to\n> empty while gettext/eval_gettext cannot be made to be no-impact like that\n> does not really matter.\n>\n>> In C, it is easy, in shell code it may be more involved.\n>\n> Correct.\n\nTo elaborate, the C code can:\n\n * Use the system gettext library to get translations.\n\n * Use the system gettext library, but effectively be pass-through\n   because the user has the C locale.\n\n * Use our fallback functions which in any modern compiler will be\n   optimized out.\n\nHowever with the shell code we can:\n\n 1. Be using the system gettext & eval_gettext to get translations.\n\n 2. Be using the system gettext & eval_gettext as pass-through, either\n    because we don't have translations since we've installed with\n    NO_GETTEXT=YesPlease, or because we're in the C locale.\n\n 3. Haven't detected that gettext.sh etc. exists, so we have to provide\n    our own fallbacks.\n\nThe proposed patch would move all users of NO_GETTEXT=YesPlease to #3,\neven though on most platforms we don't need to define our own dummy\nfallbacks since the system already provides them.\n\nI don't particularly like it because I'd rather use the OS vendor's\nimplementation if possible, even for fallback.\n\nHowever it being broken is also unacceptable, but I think the way\nforward is to detect the breakage either at compile time or at\nruntime, to that end Alex could you provide us with the output from\nthe following commands on the offending system where this is broken:\n\n    $ type gettext.sh\n    $ gettext.sh --version\n    $ gettext -h\n    $ gettext \"some test text\"\n    $ . gettext.sh\n    eval_gettext\n    $ variable=value eval_gettext \"some \\$variable\"\n\nThen how the eval_gettext function is defined:\n\n    $ type eval_gettext\n    eval_gettext is a function\n    eval_gettext ()\n    {\n        gettext \"$1\" | ( export PATH `envsubst --variables \"$1\"`;\n        envsubst \"$1\" )\n    }\n\nAnd then a --version for whatever programs that function uses,\ne.g. here:\n\n    $ envsubst --version\n\nOnce we know how it breaks we can e.g. add configure tests for\nchecking whether we can use the system's gettext library for the\nfallbacks.\n\nCould you also run the git test suite as described in t/README? I'd\nexpect a lot of the i18n tests to fail, but it would be curious to see\nwhich ones exactly.\n"},{"id":"182848","messageId":"CALxABCZWBtgX736Acoy-CCAz8RJb0EKnHf+7g72dOdVS+BOhSw@mail.gmail.com","threadId":"29383","inReplyTo":"CACBZZX7iiF2um11FvD+MBz=rZb7RrHtCJp3PqexLnSp3-Cbqug@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T10:40:38Z","receivedAt":"2012-01-20T10:40:38Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 10:50, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> However with the shell code we can:\n>\n>  1. Be using the system gettext & eval_gettext to get translations.\n>\n>  2. Be using the system gettext & eval_gettext as pass-through, either\n>    because we don't have translations since we've installed with\n>    NO_GETTEXT=YesPlease, or because we're in the C locale.\n>\n>  3. Haven't detected that gettext.sh etc. exists, so we have to provide\n>    our own fallbacks.\n>\n> The proposed patch would move all users of NO_GETTEXT=YesPlease to #3,\n> even though on most platforms we don't need to define our own dummy\n> fallbacks since the system already provides them.\n>\n> I don't particularly like it because I'd rather use the OS vendor's\n> implementation if possible, even for fallback.\n\nWell, I dunno. I wouldn't trust anything to this particular \"OS vendoer\".\n\n> However it being broken is also unacceptable, but I think the way\n> forward is to detect the breakage either at compile time or at\n> runtime, ...\n\nBetter at runtime, unless the packager explicitly stated they don't want\nany of this.\n\n> ... to that end Alex could you provide us with the output from\n> the following commands on the offending system where this is broken:\n>\n>    $ type gettext.sh\n\ngettext.sh is /usr/bin/gettext.sh\n\n>    $ gettext.sh --version\n\n/usr/bin/gettext.sh (GNU gettext-runtime) 0.18.1\nCopyright (C) 2003-2007 Free Software Foundation, Inc.\nLicense GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\nWritten by Bruno Haible\n\n>    $ gettext -h\n\nNothing. Exit code 127.\n\n>    $ gettext \"some test text\"\n\nNothing. Exit code 127.\n\n>    $ . gettext.sh\n\nNothing. Exit code 0.\n\n>    eval_gettext\n\nNothing. Exit code 127.\n\n>    $ variable=value eval_gettext \"some \\$variable\"\n\nNothing. Exit code 127.\n\n> Then how the eval_gettext function is defined:\n>\n>    $ type eval_gettext\n\neval_gettext is a function\neval_gettext ()\n{\n    gettext \"$1\" | ( export PATH `envsubst --variables \"$1\"`;\n    envsubst \"$1\" )\n}\n\n> And then a --version for whatever programs that function uses,\n> e.g. here:\n>\n>    $ envsubst --version\n\nNothing. Exit code 127.\n\n> Once we know how it breaks we can e.g. add configure tests for\n> checking whether we can use the system's gettext library for the\n> fallbacks.\n\nThe exit code seems to be a good enough test here, but testing some\noutput (or even translation) would be safer.\n\nI believe gettext (the binary) just doesn't start at all here. Maybe\nsome Cygwin library wrong or missing library. Happens all the time\nhere, as we have different Cygwin installations depending on the\ncurrently used toolchain. QNX Momentics, in particular. Different\nversions of them, and it is too cumbersome to keep them apart.\n\n> Could you also run the git test suite as described in t/README? I'd\n> expect a lot of the i18n tests to fail, but it would be curious to see\n> which ones exactly.\n\nYes, they do. Can't run them on this problematic system, because they\ntend to crash it, if run for an undetermined while. On the other system,\nwhich can run them, gettext works (it is an older Cygwin installation),\nso almost all tests pass (some still don't, but for reasons unrelated).\nStrangely enough, the problematic system can build. So I don't copy\nthe git binaries, they are actually built on that system.\n"},{"id":"182849","messageId":"1327063775-28420-1-git-send-email-avarab@gmail.com","threadId":"29383","inReplyTo":"CALxABCZWBtgX736Acoy-CCAz8RJb0EKnHf+7g72dOdVS+BOhSw@mail.gmail.com","subject":"[PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-01-20T12:49:35Z","receivedAt":"2012-01-20T12:49:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Even though we can load gettext.sh the gettext(1) and eval_gettext\nfunctions it provides might be completely broken. This reportedly\nhappens on some Cygwin installations where we can load gettext.sh, but\ngettext and eval_gettext both return exit code 127 and no output.\n\nThe reason we're trying to load gettext.sh (or the equivalent Solaris\nimplementation) at all is so we don't have to provide our own fallback\nimplementation if the OS already has one installed, but because we\ndidn't test whether it actually worked under GNU gettext we might end\nup with broken functions.\n\nChange the detection in git-sh-i18n so that it tests that the output\nof \"gettext test\" produces \"test\", on Solaris we already test that\n\"gettext -h\" produces \"-h\", so we were already guarded against the\nsame sort of failure there.\n\nReported-by: Alex Riesen <raa.lkml@gmail.com>\n---\nHere's a minimal patch to git-sh-i18n that should make things work on\nCygwin and any other platforms with broken gettext functions while\nalso using the OS-provided functions if they work.\n\nI've added a new t0201-gettext-fallbacks-broken-gettext.sh test that\ntests this. This required a small change in lib-gettext.sh so I\nwouldn't load test-lib.sh twice.\n\nNote that there's already a t0201* test in the repo. Maybe we want to\nincrement all the gettext test numbers by one to make room for it?\n\nAs an aside I'm really not a big fan of having hardcoded numbers in\nthe test files like this. We don't care about the order of execution\nhere.\n\n git-sh-i18n.sh                              |    2 +-\n t/lib-gettext.sh                            |    7 +++++-\n t/t0201-gettext-fallbacks-broken-gettext.sh |   28 +++++++++++++++++++++++++++\n 3 files changed, 35 insertions(+), 2 deletions(-)\n create mode 100755 t/t0201-gettext-fallbacks-broken-gettext.sh\n\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..26a57b0 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -18,7 +18,7 @@ export TEXTDOMAINDIR\n \n if test -z \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n+\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1 && test \"$(gettext test 2>&1)\" = \"test\"\n \tthen\n \t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n \t\t# else than setting up the environment and loading gettext.sh\ndiff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\nindex 0f76f6c..2c5b758 100644\n--- a/t/lib-gettext.sh\n+++ b/t/lib-gettext.sh\n@@ -3,7 +3,12 @@\n # Copyright (c) 2010 Ævar Arnfjörð Bjarmason\n #\n \n-. ./test-lib.sh\n+if test -z \"$TEST_DIRECTORY\"\n+then\n+\t# In case the test loaded test-lib.sh by itself to do some tests\n+\t# prior to loading us.\n+\t. ./test-lib.sh\n+fi\n \n GIT_TEXTDOMAINDIR=\"$GIT_BUILD_DIR/po/build/locale\"\n GIT_PO_PATH=\"$GIT_BUILD_DIR/po\"\ndiff --git a/t/t0201-gettext-fallbacks-broken-gettext.sh b/t/t0201-gettext-fallbacks-broken-gettext.sh\nnew file mode 100755\nindex 0000000..92b95ae\n--- /dev/null\n+++ b/t/t0201-gettext-fallbacks-broken-gettext.sh\n@@ -0,0 +1,28 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2012 Ævar Arnfjörð Bjarmason\n+#\n+\n+test_description='Gettext Shell fallbacks with broken gettext'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'set up a fake broken gettext(1)' '\n+\tcat >gettext <<-\\EOF &&\n+\t#!/bin/sh\n+\texit 1\n+\tEOF\n+\tchmod +x gettext &&\n+    ! ./gettext\n+'\n+\n+PATH=.:$PATH\n+. \"$TEST_DIRECTORY\"/lib-gettext.sh\n+\n+test_expect_success C_LOCALE_OUTPUT '$GIT_INTERNAL_GETTEXT_SH_SCHEME\" is fallthrough with broken gettext(1)' '\n+    echo fallthrough >expect &&\n+    echo $GIT_INTERNAL_GETTEXT_SH_SCHEME >actual &&\n+    test_cmp expect actual\n+'\n+\n+test_done\n-- \n1.7.7.3\n"},{"id":"182853","messageId":"CALxABCYgYT=K0CRJKFOJAeB2wb=vRbwd--YEQtvofA5fmq_t-A@mail.gmail.com","threadId":"29383","inReplyTo":"1327063775-28420-1-git-send-email-avarab@gmail.com","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T14:02:40Z","receivedAt":"2012-01-20T14:02:40Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 13:49, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> Even though we can load gettext.sh the gettext(1) and eval_gettext\n> functions it provides might be completely broken. This reportedly\n> happens on some Cygwin installations where we can load gettext.sh, but\n> gettext and eval_gettext both return exit code 127 and no output.\n>\n> The reason we're trying to load gettext.sh (or the equivalent Solaris\n> implementation) at all is so we don't have to provide our own fallback\n> implementation if the OS already has one installed, but because we\n> didn't test whether it actually worked under GNU gettext we might end\n> up with broken functions.\n>\n> Change the detection in git-sh-i18n so that it tests that the output\n> of \"gettext test\" produces \"test\", on Solaris we already test that\n> \"gettext -h\" produces \"-h\", so we were already guarded against the\n> same sort of failure there.\n>\n> Reported-by: Alex Riesen <raa.lkml@gmail.com>\n> ---\n> Here's a minimal patch to git-sh-i18n that should make things work on\n> Cygwin and any other platforms with broken gettext functions while\n> also using the OS-provided functions if they work.\n\nFWIW, I confirm it works (which is quite obvious).\n\nJust for giggles, I even risked running the tests and, of course, crashed\nthat piece of junk with broken Cygwin installation.\nPlease don't ask me to do that again :) restarting it is PITA as well.\n\nJust for future reference to all poor Cygwin users:\n\nI also left NO_GETTEXT in the config.mak. This, BTW, explains why git\nworks, while gettext binary does not: one .dll dependency less.\n"},{"id":"182871","messageId":"7vsjjadv5g.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CALxABCZWBtgX736Acoy-CCAz8RJb0EKnHf+7g72dOdVS+BOhSw@mail.gmail.com","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T19:35:39Z","receivedAt":"2012-01-20T19:35:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n>> And then a --version for whatever programs that function uses,\n>> e.g. here:\n>>\n>>    $ envsubst --version\n>\n> Nothing. Exit code 127.\n\nInteresting.\n\n    $ wonbsubst --version; echo $?\n    bash: wonbsubst: command not found\n    127\n\nPerhaps your distro lacks a necessary package dependencies between gettext\nand envsubst?\n\n> I believe gettext (the binary) just doesn't start at all here. Maybe\n> some Cygwin library wrong or missing library. Happens all the time\n> here,...\n\nAha.\n\nI guess we either leave it broken for broken installation or add an extra\n\"MY_GETTEXT_IS_BROKEN\" option; in either way, it does not sound like a\nserious enough issue that is widespread to be urgently fixed during the\nfeature freeze.\n"},{"id":"182872","messageId":"CALxABCYSH4KOtss96dtu8tw0SQd4yFuCaX+XajAY4Fbrdez+7Q@mail.gmail.com","threadId":"29383","inReplyTo":"7vsjjadv5g.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T19:45:37Z","receivedAt":"2012-01-20T19:45:37Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 20:35, Junio C Hamano <gitster@pobox.com> wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n>\n>>> And then a --version for whatever programs that function uses,\n>>> e.g. here:\n>>>\n>>>    $ envsubst --version\n>>\n>> Nothing. Exit code 127.\n>\n> Interesting.\n>\n>    $ wonbsubst --version; echo $?\n>    bash: wonbsubst: command not found\n>    127\n>\n> Perhaps your distro lacks a necessary package dependencies between gettext\n> and envsubst?\n>\n>> I believe gettext (the binary) just doesn't start at all here. Maybe\n>> some Cygwin library wrong or missing library. Happens all the time\n>> here,...\n>\n> Aha.\n>\n> I guess we either leave it broken for broken installation or add an extra\n> \"MY_GETTEXT_IS_BROKEN\" option; in either way, it does not sound like a\n> serious enough issue that is widespread to be urgently fixed during the\n> feature freeze.\n\nÆvar already posted a very cute little fix for this, which looks\npretty minimal and is very obvious.\n\nP.S. Sorry for html mail before (tried to use the Android Gmail client).\n"},{"id":"182873","messageId":"7vobtydu0o.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"1327063775-28420-1-git-send-email-avarab@gmail.com","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T20:00:07Z","receivedAt":"2012-01-20T20:00:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Here's a minimal patch to git-sh-i18n that should make things work on\n> Cygwin and any other platforms with broken gettext functions while\n> also using the OS-provided functions if they work.\n\n> I've added a new t0201-gettext-fallbacks-broken-gettext.sh test that\n> tests this. This required a small change in lib-gettext.sh so I\n> wouldn't load test-lib.sh twice.\n>\n> Note that there's already a t0201* test in the repo. Maybe we want to\n> increment all the gettext test numbers by one to make room for it?\n>\n> As an aside I'm really not a big fan of having hardcoded numbers in\n> the test files like this. We don't care about the order of execution\n> here.\n\nWe do not care the order but we do care about the uniqueness in parallel\ntest execution.\n\nIt does appear that we need a bit better preprocessing of git-sh-i18n at\nthe compile time now. How about applying the restructuring shown in the\npatch by Alex (without the @@NO_GETTEXT@@ bit) first without changing any\nlogic, then try making the \"First decide what scheme to use\" part lighter\nweight by replacing the runtime \"type gettext.sh\" and such checks with\nsome preprocessing?\n\nIOW, the first step would look like the attached patch, and then we can\nreplace the entire \"First decide\" part if/elif/fi chain with just this:\n\n\t# The scheme to use\n        : ${GIT_INTERNAL_GETTEXT_SH_SCHEME:=@@GETTEXT_SH_SCHEME@@}\n\nso that t/lib-gettext.sh can define and export GIT_INTERNAL_GETTEXT_SH to\nalways get what it wants to test (fallthrough?). At build time, instead\nof, or in addition to, the $(cmd_munge_script), we could replace the\nsingle @@GETTEXT_SH_SCHEME@@ token above with whatever scheme we want to\nuse to hardcode the decision we make at the compile time.\n\nHmm?\n\n git-sh-i18n.sh |  103 +++++++++++++++++++++++++++-----------------------------\n 1 files changed, 50 insertions(+), 53 deletions(-)\n\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 26a57b0..6648bd3 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -16,61 +16,45 @@ else\n fi\n export TEXTDOMAINDIR\n \n-if test -z \"$GIT_GETTEXT_POISON\"\n+# First decide what scheme to use...\n+GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n+if test -n \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n+then\n+\t: no probing necessary\n+elif test -n \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1 && test \"$(gettext test 2>&1)\" = \"test\"\n-\tthen\n-\t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n-\t\t# else than setting up the environment and loading gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Try to use libintl's gettext.sh, or fall back to English if we\n-\t\t# can't.\n-\t\t. gettext.sh\n-\n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n-\tthen\n-\t\t# We don't have gettext.sh, but there's a gettext binary in our\n-\t\t# path. This is probably Solaris or something like it which has a\n-\t\t# gettext implementation that isn't GNU libintl.\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Solaris has a gettext(1) but no eval_gettext(1)\n-\t\teval_gettext () {\n-\t\t\tgettext \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\n-\telse\n-\t\t# Since gettext.sh isn't available we'll have to define our own\n-\t\t# dummy pass-through functions.\n-\n-\t\t# Tell our tests that we don't have the real gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\tgettext () {\n-\t\t\tprintf \"%s\" \"$1\"\n-\t\t}\n-\n-\t\teval_gettext () {\n-\t\t\tprintf \"%s\" \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\tfi\n-else\n-\t# Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests\n-\t# this relies on an environment variable\n-\n \tGIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n-\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n+elif type gettext.sh >/dev/null 2>&1\n+then\n+\t# GNU libintl's gettext.sh\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n+elif test \"$(gettext -h 2>&1)\" = \"-h\"\n+then\n+\t# gettext binary exists but no gettext.sh. likely to be a gettext\n+\t# binary on a Solaris or something that is not GNU libintl and\n+\t# lack eval_gettext.\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext\n+fi\n+export GIT_INTERNAL_GETTEXT_SH_SCHEME\n \n+# ... and then follow that decision.\n+case \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" in\n+gnu)\n+\t# Use libintl's gettext.sh, or fall back to English if we can't.\n+\t. gettext.sh\n+\t;;\n+gettext_without_eval_gettext)\n+\t# Solaris has a gettext(1) but no eval_gettext(1)\n+\teval_gettext () {\n+\t\tgettext \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+poison)\n+\t# Emit garbage so that tests that incorrectly rely on translatable\n+\t# strings will fail.\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n@@ -78,7 +62,20 @@ else\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n-fi\n+\t;;\n+*)\n+\tgettext () {\n+\t\tprintf \"%s\" \"$1\"\n+\t}\n+\n+\teval_gettext () {\n+\t\tprintf \"%s\" \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+esac\n \n # Git-specific wrapper functions\n gettextln () {\n"},{"id":"182874","messageId":"CALxABCZJATyVRf9akmfpn3WpJ8Xt80Ky0isFOTwDGpFKvFp3nw@mail.gmail.com","threadId":"29383","inReplyTo":"7vobtydu0o.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T20:13:01Z","receivedAt":"2012-01-20T20:13:01Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 21:00, Junio C Hamano <gitster@pobox.com> wrote:\n> IOW, the first step would look like the attached patch, and then we can\n> replace the entire \"First decide\" part if/elif/fi chain with just this:\n>\n>        # The scheme to use\n>        : ${GIT_INTERNAL_GETTEXT_SH_SCHEME:=@@GETTEXT_SH_SCHEME@@}\n>\n> so that t/lib-gettext.sh can define and export GIT_INTERNAL_GETTEXT_SH to\n> always get what it wants to test (fallthrough?). At build time, instead\n> of, or in addition to, the $(cmd_munge_script), we could replace the\n> single @@GETTEXT_SH_SCHEME@@ token above with whatever scheme we want to\n> use to hardcode the decision we make at the compile time.\n\nI can imagine a Solaris system being upgraded to GNU gettext _after_ Git\ninstallation. Hardcoding the decision might break git scripts then.\n"},{"id":"182875","messageId":"7vfwfadt10.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CALxABCZJATyVRf9akmfpn3WpJ8Xt80Ky0isFOTwDGpFKvFp3nw@mail.gmail.com","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T20:21:31Z","receivedAt":"2012-01-20T20:21:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n>> ... At build time, instead\n>> of, or in addition to, the $(cmd_munge_script), we could replace the\n>> single @@GETTEXT_SH_SCHEME@@ token above with whatever scheme we want to\n>> use to hardcode the decision we make at the compile time.\n>\n> I can imagine a Solaris system being upgraded to GNU gettext _after_ Git\n> installation. Hardcoding the decision might break git scripts then.\n\nJust like you would break http transport by removing libcurl after\ninstalling Git? What else is new?\n"},{"id":"182876","messageId":"CALxABCZnz-8BuXf=-HrH7UZXi6pQ3VzL4HrOKgKHqWwUMnwJQA@mail.gmail.com","threadId":"29383","inReplyTo":"7vfwfadt10.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T20:24:00Z","receivedAt":"2012-01-20T20:24:00Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 21:21, Junio C Hamano <gitster@pobox.com> wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n>\n>>> ... At build time, instead\n>>> of, or in addition to, the $(cmd_munge_script), we could replace the\n>>> single @@GETTEXT_SH_SCHEME@@ token above with whatever scheme we want to\n>>> use to hardcode the decision we make at the compile time.\n>>\n>> I can imagine a Solaris system being upgraded to GNU gettext _after_ Git\n>> installation. Hardcoding the decision might break git scripts then.\n>\n> Just like you would break http transport by removing libcurl after\n> installing Git? What else is new?\n\nRemoving - yes, upgrading it - very unlikely. Besides, the current version\nwont have problems with such an upgrade.\n"},{"id":"182877","messageId":"7vbopydst0.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CALxABCZnz-8BuXf=-HrH7UZXi6pQ3VzL4HrOKgKHqWwUMnwJQA@mail.gmail.com","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-20T20:26:19Z","receivedAt":"2012-01-20T20:26:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> .... Besides, the current version\n> wont have problems with such an upgrade.\n\nYes, but at what cost?\n"},{"id":"182878","messageId":"CALxABCZAaNwxJJRsMo7ESTP1sskjXbhk+OvPWOybS==D8FwNUA@mail.gmail.com","threadId":"29383","inReplyTo":"7vbopydst0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-20T20:33:35Z","receivedAt":"2012-01-20T20:33:35Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Jan 20, 2012 at 21:26, Junio C Hamano <gitster@pobox.com> wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n>\n>> .... Besides, the current version\n>> wont have problems with such an upgrade.\n>\n> Yes, but at what cost?\n\nA fixed number of \"fork and exec\" for every executed \". git-sh-i18n\" line?\nThe overhead might be considered negligible...\n\nEr. Am I missing something very obvious? (not obvious to me, yet)\n"},{"id":"182984","messageId":"7v1uqq84es.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"20120119195222.GA5011@blimp.dmz","subject":"Re: [PATCH] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-23T22:01:15Z","receivedAt":"2012-01-23T22:01:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Some systems have gettext.sh (GNU gettext) installed, but it is either broken\n> or misconfigured in such a way so its output is not usable.\n> For instance, on this particular system, a Cygwin installations gettext\n> produces no output whatsoever.\n>\n> In case the users of these systems are unable or not interested in fixing\n> them, setting the new Makefile switch should help:\n>\n>     USE_FALLTHROUGH_GETTEXT_SCHEME=yes\n>\n> This will replace the translation routines with fallthrough versions, which\n> currently used only for regression testing.\n>\n> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>\n> ---\n\nI'll split this into two, the first one only to restructure the code and\nthe guts of this one that avoids the autodetection.\n\nAlso I'd rename this so that:\n\n\t$ make USE_GETTEXT_SCHEME=fallthrough\n\t$ make USE_GETTEXT_SCHEME=gnu\n\ncould be used to avoid extra and unnecessary runtime overhead when the\nperson building git knows what is on the system.\n"},{"id":"182985","messageId":"7vwr8i6prk.fsf_-_@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"7v1uqq84es.fsf@alter.siamese.dyndns.org","subject":"[PATCH 1/2] git-sh-i18n: restructure the logic to compute gettext.sh scheme","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-23T22:02:55Z","receivedAt":"2012-01-23T22:02:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Instead of having a single long and complex chain of commands to decide\nwhat to do and carry out the decision, split the code so that we first\ndecide which scheme to use, and in the second section define what exactly\nis done by the chosen scheme. It makes the code much easier to follow and\nupdate.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-sh-i18n.sh |  103 +++++++++++++++++++++++++++-----------------------------\n 1 files changed, 50 insertions(+), 53 deletions(-)\n\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex b4575fb..6648bd3 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -16,61 +16,45 @@ else\n fi\n export TEXTDOMAINDIR\n \n-if test -z \"$GIT_GETTEXT_POISON\"\n+# First decide what scheme to use...\n+GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n+if test -n \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n+then\n+\t: no probing necessary\n+elif test -n \"$GIT_GETTEXT_POISON\"\n then\n-\tif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && type gettext.sh >/dev/null 2>&1\n-\tthen\n-\t\t# This is GNU libintl's gettext.sh, we don't need to do anything\n-\t\t# else than setting up the environment and loading gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Try to use libintl's gettext.sh, or fall back to English if we\n-\t\t# can't.\n-\t\t. gettext.sh\n-\n-\telif test -z \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\" && test \"$(gettext -h 2>&1)\" = \"-h\"\n-\tthen\n-\t\t# We don't have gettext.sh, but there's a gettext binary in our\n-\t\t# path. This is probably Solaris or something like it which has a\n-\t\t# gettext implementation that isn't GNU libintl.\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=solaris\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\t# Solaris has a gettext(1) but no eval_gettext(1)\n-\t\teval_gettext () {\n-\t\t\tgettext \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\n-\telse\n-\t\t# Since gettext.sh isn't available we'll have to define our own\n-\t\t# dummy pass-through functions.\n-\n-\t\t# Tell our tests that we don't have the real gettext.sh\n-\t\tGIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n-\t\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n-\n-\t\tgettext () {\n-\t\t\tprintf \"%s\" \"$1\"\n-\t\t}\n-\n-\t\teval_gettext () {\n-\t\t\tprintf \"%s\" \"$1\" | (\n-\t\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n-\t\t\t\tgit sh-i18n--envsubst \"$1\"\n-\t\t\t)\n-\t\t}\n-\tfi\n-else\n-\t# Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests\n-\t# this relies on an environment variable\n-\n \tGIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n-\texport GIT_INTERNAL_GETTEXT_SH_SCHEME\n+elif type gettext.sh >/dev/null 2>&1\n+then\n+\t# GNU libintl's gettext.sh\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gnu\n+elif test \"$(gettext -h 2>&1)\" = \"-h\"\n+then\n+\t# gettext binary exists but no gettext.sh. likely to be a gettext\n+\t# binary on a Solaris or something that is not GNU libintl and\n+\t# lack eval_gettext.\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext\n+fi\n+export GIT_INTERNAL_GETTEXT_SH_SCHEME\n \n+# ... and then follow that decision.\n+case \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" in\n+gnu)\n+\t# Use libintl's gettext.sh, or fall back to English if we can't.\n+\t. gettext.sh\n+\t;;\n+gettext_without_eval_gettext)\n+\t# Solaris has a gettext(1) but no eval_gettext(1)\n+\teval_gettext () {\n+\t\tgettext \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+poison)\n+\t# Emit garbage so that tests that incorrectly rely on translatable\n+\t# strings will fail.\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n@@ -78,7 +62,20 @@ else\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n-fi\n+\t;;\n+*)\n+\tgettext () {\n+\t\tprintf \"%s\" \"$1\"\n+\t}\n+\n+\teval_gettext () {\n+\t\tprintf \"%s\" \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n+\t;;\n+esac\n \n # Git-specific wrapper functions\n gettextln () {\n-- \n1.7.9.rc2.48.g92994\n"},{"id":"182986","messageId":"7vr4yq6poy.fsf_-_@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"7vwr8i6prk.fsf_-_@alter.siamese.dyndns.org","subject":"[PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-23T22:04:29Z","receivedAt":"2012-01-23T22:04:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nSome systems have gettext.sh (GNU gettext) installed, but it is either\nbroken or misconfigured in such a way so its output is not usable.  In\ncase the users of these systems are unable or not interested in fixing\nthem, setting the new Makefile switch should help:\n\n    make USE_GETTEXT_SCHEME=fallthrough\n\nThis will replace the translation routines with fallthrough versions,\nthat does not use gettext from the platform.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Makefile       |    4 ++++\n git-sh-i18n.sh |    5 ++++-\n 2 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 9470a10..4435854 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -47,6 +47,9 @@ all::\n # A translated Git requires GNU libintl or another gettext implementation,\n # plus libintl-perl at runtime.\n #\n+# Define USE_GETTEXT_SCHEME and set it to 'fallthrough', if you don't trust\n+# the installed gettext translation of the shell scripts output.\n+#\n # Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't\n # trust the langinfo.h's nl_langinfo(CODESET) function to return the\n # current character set. GNU and Solaris have a nl_langinfo(CODESET),\n@@ -1874,6 +1877,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n+    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\n     $@.sh >$@+\n endef\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 6648bd3..d5fae99 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -18,7 +18,10 @@ export TEXTDOMAINDIR\n \n # First decide what scheme to use...\n GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough\n-if test -n \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n+if test -n \"@@USE_GETTEXT_SCHEME@@\"\n+then\n+\tGIT_INTERNAL_GETTEXT_SH_SCHEME=\"@@USE_GETTEXT_SCHEME@@\"\n+elif test -n \"@@USE_FALLTHROUGH_GETTEXT_SCHEME@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n then\n \t: no probing necessary\n elif test -n \"$GIT_GETTEXT_POISON\"\n-- \n1.7.9.rc2.48.g92994\n"},{"id":"182987","messageId":"20120123221256.GG20833@burratino","threadId":"29383","inReplyTo":"7vr4yq6poy.fsf_-_@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-23T22:12:56Z","receivedAt":"2012-01-23T22:12:56Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n>     make USE_GETTEXT_SCHEME=fallthrough\n>\n> This will replace the translation routines with fallthrough versions,\n> that does not use gettext from the platform.\n\nNice implementation.  I still don't understand why NO_GETTEXT=YesPlease\nshould not imply this.  Is it to ensure the GETTEXT_SCHEME=gnu mode\ngets more testing?\n\nHere's a patch to consider squashing in that makes the option take\neffect if it changes between builds.\n\ndiff --git i/Makefile w/Makefile\nindex 63dfd64d..b2b738bb 100644\n--- i/Makefile\n+++ w/Makefile\n@@ -2268,7 +2268,7 @@ cscope:\n ### Detect prefix changes\n TRACK_CFLAGS = $(CC):$(subst ','\\'',$(ALL_CFLAGS)):\\\n              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\\\n-             $(localedir_SQ)\n+             $(localedir_SQ):$(USE_GETTEXT_SCHEME)\n \n GIT-CFLAGS: FORCE\n \t@FLAGS='$(TRACK_CFLAGS)'; \\\n"},{"id":"182989","messageId":"7vehuq6ote.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"20120123221256.GG20833@burratino","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-23T22:23:25Z","receivedAt":"2012-01-23T22:23:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>>     make USE_GETTEXT_SCHEME=fallthrough\n>>\n>> This will replace the translation routines with fallthrough versions,\n>> that does not use gettext from the platform.\n>\n> Nice implementation.  I still don't understand why NO_GETTEXT=YesPlease\n> should not imply this.\n\nShould be easy to do so, like this?\n\ndiff --git a/Makefile b/Makefile\nindex a782409..c4c1066 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1521,6 +1521,7 @@ ifdef GETTEXT_POISON\n endif\n ifdef NO_GETTEXT\n \tBASIC_CFLAGS += -DNO_GETTEXT\n+\tUSE_GETTEXT_SCHEME = fallthrough\n endif\n ifdef NO_STRCASESTR\n \tCOMPAT_CFLAGS += -DNO_STRCASESTR\n"},{"id":"182993","messageId":"20120123224016.GH20833@burratino","threadId":"29383","inReplyTo":"7vehuq6ote.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-23T22:40:16Z","receivedAt":"2012-01-23T22:40:16Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> Nice implementation.  I still don't understand why NO_GETTEXT=YesPlease\n>> should not imply this.\n>\n> Should be easy to do so, like this?\n>\n> diff --git a/Makefile b/Makefile\n> index a782409..c4c1066 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1521,6 +1521,7 @@ ifdef GETTEXT_POISON\n>  endif\n>  ifdef NO_GETTEXT\n>  \tBASIC_CFLAGS += -DNO_GETTEXT\n> +\tUSE_GETTEXT_SCHEME = fallthrough\n>  endif\n\nYep, that would make my worries about intuitive behavior evaporate. :)\n(Maybe \"USE_GETTEXT_SCHEME ?= fallthrough\" to make it easier to\noverride in config.mak.)\n\nThanks.  I also would not actually mind the behavior without that\ntweak, as long as it's explained somewhere.\n\nCiao,\nJonathan\n"},{"id":"182996","messageId":"20120124003109.GB26980@burratino","threadId":"29383","inReplyTo":"7vehuq6ote.fsf@alter.siamese.dyndns.org","subject":"[PATCH/RFC 3/2] i18n: do not use gettext.sh by default when NO_GETTEXT is set","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-01-24T00:31:09Z","receivedAt":"2012-01-24T00:31:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nWhen NO_GETTEXT is set, even if a usable installed gettext.sh is\ndetected to be present, it can only help to use git's simple fallback\nstub implementations of gettext and eval_gettext for shell scripts\ninstead.  That way:\n\n 1) we avoid the complication of autodetection of gettext.sh support\n    at runtime;\n\n 2) in particular, if the operating system provides gettext.sh but\n    it is unusable, we will not be tricked into trying to use it.\n\nSo this patch makes USE_GETTEXT_SCHEME default to fallthrough when\nNO_GETTEXT is set.  This is only a default so the operator can set\nUSE_GETTEXT_SCHEME=gnu or ...=gettext_without_eval_gettext to try the\nother schemes.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJunio C Hamano wrote:\n\n> Should be easy to do so, like this?\n\nProbably too late to be useful, but here's a patch with commit message\nimplementing the same.\n\n Makefile |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex b2b738bb..e9b4a2f9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1524,6 +1524,9 @@ ifdef GETTEXT_POISON\n endif\n ifdef NO_GETTEXT\n \tBASIC_CFLAGS += -DNO_GETTEXT\n+\tifndef USE_GETTEXT_SCHEME\n+\t\tUSE_GETTEXT_SCHEME = fallthrough\n+\tendif\n endif\n ifdef NO_STRCASESTR\n \tCOMPAT_CFLAGS += -DNO_STRCASESTR\n-- \n1.7.9.rc2\n"},{"id":"182999","messageId":"CACBZZX66-JsS4zZXwv2squcjYUS8v+9cN0hv23t5nMHA+1k9XQ@mail.gmail.com","threadId":"29383","inReplyTo":"20120123221256.GG20833@burratino","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-01-24T00:39:26Z","receivedAt":"2012-01-24T00:39:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Jan 23, 2012 at 23:12, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Junio C Hamano wrote:\n>\n>>     make USE_GETTEXT_SCHEME=fallthrough\n>>\n>> This will replace the translation routines with fallthrough versions,\n>> that does not use gettext from the platform.\n>\n> Nice implementation.  I still don't understand why NO_GETTEXT=YesPlease\n> should not imply this.  Is it to ensure the GETTEXT_SCHEME=gnu mode\n> gets more testing?\n\nI was the only one with an objection to doing that. The main (and I\nadmit, at least slightly irrational) reason being that I simply don't\nlike using fallback functions when the system supplies us with\nperfectly good functions we can use instead.\n\nIt means we're less likely to share code / fixes / eyeballs / cache\nwith other programs. I.e. by using envsubst(1) instead of\ngit-sh-i18n--envsubst--variables(1).\n\nIronically this is all my fault by naming the option for turning off\ntranslations NO_GETTEXT. What it should be called is\nDO_NOT_TRANSLATE_OUTPUT, but since we *need* shell functions to output\nanything it might have used a system gettext library to do that,\nNO_GETTEXT should have been \"I don't have any gettext library, please\nsupply some fallbacks\".\n\nWhich would have meant that for people who simply don't want\ntranslated output we'd be using the maintained by upstream envsubst(1)\ninstead of the doomed to bitrot forever hack I ripped out of some old\nGPL2 version of GNU gettext.\n\nAnyway in the grand scheme of things none of this really matters,\nthese patches can all go in as far as I'm concerned. I can submit\npatches to improve it once the dust has settled if I still care\nenough.\n\nAside from this I think not having the ability to run a pre-processor\non the shellscripts results in some really ugly workarounds. This\nstuff would be much nicer if we could just generate git-sh-i18n.sh at\ncompile time depending on some autoconf tests or Makefile options.\n\nAnd by hacking up a pre-processor that just searches/replaces all the\ngettext/eval_gettext calls out of the shell code we could sidestep\nthis whole issue and there wouldn't be any need for fallback\nfunctions, ever. This would also result in a real improvement on\nWindows where exec overhead is much larger.\n\nLike this hack, which doesn't even work, but gives you some idea of\nwhat we could do:\n\n    #!/usr/bin/env perl\n    BEGIN { $^I = \"\"; }\n\n    sub unescape {\n    \tmy $str = shift;\n    \t$str =~ s/\\\\\\$/\\$/gs;\n    \t$str;\n    }\n\n    LINE: while (defined($_ = <ARGV>)) {\n    \ts[\"\\$\\(gettext \"([^\"]+?)\"\\)\"][\"$1\"]g;\n    \ts[\"\\$\\(eval_gettext \"([^\"]+?)\"\\)\"]['\"' . unescape($1) . '\"']eg;\n    \ts[eval_gettextln \"([^\"]+?)\"]['echo \"' . unescape($1) . '\"']eg;\n    \ts[gettext \"([^\"]+?)\"][printf \"%s\" \"$1\"]g;\n    \ts[gettextln \"([^\"]+?)\"][echo \"$1\"]g;\n    #\ts[gettextln \"([^\"]+?)\"][echo \"$1\"]g;\n    #\ts/foo/bar/;\n    \tprint;\n\n    }\n\n\nWhen run:\n\n    for f in $(git grep -l gettext -- *.sh); do perl replace-gettext.pl $f; done\n\nProduces output like:\n\n    @@ -351 +351 @@ split_patches () {\n    -                       clean_abort \"$(eval_gettext \"Patch format\n\\$patch_format is not supported.\")\"\n    +                       clean_abort \"Patch format $patch_format is\nnot supported.\"\n    @@ -353 +353 @@ split_patches () {\n    -                       clean_abort \"$(gettext \"Patch format\ndetection failed.\")\"\n    +                       clean_abort \"Patch format detection failed.\"\n    @@ -403 +403 @@ do\n    -               die \"$(gettext \"-d option is no longer supported.\nDo not use.\")\"\n    +               die \"-d option is no longer supported.  Do not use.\"\n    @@ -466 +466 @@ then\n    -       die \"$(eval_gettext \"previous rebase directory \\$dotest\nstill exists but mbox given.\")\"\n    +       die \"previous rebase directory $dotest still exists but mbox given.\"\n\nIt would be relatively easy to hack up a basic POSIX shell\npre-processor like this that would work on our *.sh files, thus\neliminating the need for all of this fallback business.\n"},{"id":"183029","messageId":"CALxABCZ0j-Pb9d9GTvkcWjmsWpmy+bUmwMWkwUTEzui5Oir_BQ@mail.gmail.com","threadId":"29383","inReplyTo":"20120123221256.GG20833@burratino","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-24T19:59:19Z","receivedAt":"2012-01-24T19:59:19Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Mon, Jan 23, 2012 at 23:12, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Here's a patch to consider squashing in that makes the option take\n> effect if it changes between builds.\n\nWhich actually bit me once, when I was playing with the code :)\n"},{"id":"183030","messageId":"CALxABCaGMabTLcCiYLv31YCiVY4OK7yEr4KL6e-0UMttMjGA_g@mail.gmail.com","threadId":"29383","inReplyTo":"7vr4yq6poy.fsf_-_@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-24T20:00:10Z","receivedAt":"2012-01-24T20:00:10Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Mon, Jan 23, 2012 at 23:04, Junio C Hamano <gitster@pobox.com> wrote:\n> From: Alex Riesen <raa.lkml@gmail.com>\n>\n> Some systems have gettext.sh (GNU gettext) installed, but it is either\n> broken or misconfigured in such a way so its output is not usable.  In\n> case the users of these systems are unable or not interested in fixing\n> them, setting the new Makefile switch should help:\n>\n>    make USE_GETTEXT_SCHEME=fallthrough\n>\n> This will replace the translation routines with fallthrough versions,\n> that does not use gettext from the platform.\n>\n> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nAmen :)\n"},{"id":"183032","messageId":"CALxABCahouHey0Q7VHm1EQVvpP_ROnOhtW=FcnZOS1UJ2KHEJA@mail.gmail.com","threadId":"29383","inReplyTo":"20120124003109.GB26980@burratino","subject":"Re: [PATCH/RFC 3/2] i18n: do not use gettext.sh by default when NO_GETTEXT is set","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2012-01-24T20:06:13Z","receivedAt":"2012-01-24T20:06:13Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Jan 24, 2012 at 01:31, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> +       ifndef USE_GETTEXT_SCHEME\n> +               USE_GETTEXT_SCHEME = fallthrough\n> +       endif\n\nWe already use GNU make features (+=), so this can be just\n\nUSE_GETTEXT_SCHEME ?= fallthrough\n\nI think...\n"},{"id":"183034","messageId":"7vpqe83llx.fsf@alter.siamese.dyndns.org","threadId":"29383","inReplyTo":"CALxABCaGMabTLcCiYLv31YCiVY4OK7yEr4KL6e-0UMttMjGA_g@mail.gmail.com","subject":"Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-24T20:13:14Z","receivedAt":"2012-01-24T20:13:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> Amen :)\n\nThanks.\n"}]}