{"thread":{"id":"28031","subject":"[RFC] gettext: add gettextln, eval_gettextln to encode common idiom","startedAt":"2011-08-06T04:16:04Z","lastAt":"2011-08-06T11:53:12Z","messageCount":3,"participants":["Jon Seymour","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"173003","messageId":"1312604164-19980-1-git-send-email-jon.seymour@gmail.com","threadId":"28031","inReplyTo":null,"subject":"[RFC] gettext: add gettextln, eval_gettextln to encode common idiom","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-06T04:16:04Z","receivedAt":"2011-08-06T04:16:04Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Currently, if you want to use gettext or eval_gettext to format a message\nyou may have to add a separate echo statement and a surrounding subshell\nin order to interpolate the required trailing new line.\n\nThis patch introduces two new helper functions, gettextln and eval_gettextln\nwhich append a trailing newline to the gettext output.\n\nThis allows constructions of the form:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\t(\n\t\t\tgettext \"You need to give me at least one good and one bad revisions.\n(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" &&\n\t\t\techo\n\t\t) >&2\n\telse\n\t...\n\nto be expressed more concisely as:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\tgettextln \"You need to give me at least one good and one bad revisions.\n+(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" >&2\n\telse\n\t...\n\nAn example of its use in git-bisect.sh is given.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-bisect.sh  |   49 ++++++++++++++-----------------------------------\n git-sh-i18n.sh |   19 +++++++++++++++++++\n 2 files changed, 33 insertions(+), 35 deletions(-)\n\nThis patch applies on top of Junio's \"bisect: further style nitpicks\" currently in kernel/pu.\n\nFWIW, I am not attached to the suggested names. I can split the changes to git-sh-i18n.sh into a separate commit if there is agreement in principle to take the change.\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 22c4da5..22c0e28 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -46,10 +46,7 @@ bisect_head()\n \n bisect_autostart() {\n \ttest -s \"$GIT_DIR/BISECT_START\" || {\n-\t\t(\n-\t\t\tgettext \"You need to start by \\\"git bisect start\\\"\" &&\n-\t\t\techo\n-\t\t) >&2\n+\t\tgettextln \"You need to start by \\\"git bisect start\\\"\" >&2\n \t\tif test -t 0\n \t\tthen\n \t\t\t# TRANSLATORS: Make sure to include [Y] and [n] in your\n@@ -268,10 +265,7 @@ bisect_next_check() {\n \tt,,good)\n \t\t# have bad but not good.  we could bisect although\n \t\t# this is less optimum.\n-\t\t(\n-\t\t\tgettext \"Warning: bisecting only with a bad commit.\" &&\n-\t\t\techo\n-\t\t) >&2\n+\t\tgettextln \"Warning: bisecting only with a bad commit.\" >&2\n \t\tif test -t 0\n \t\tthen\n \t\t\t# TRANSLATORS: Make sure to include [Y] and [n] in your\n@@ -287,18 +281,12 @@ bisect_next_check() {\n \n \t\tif test -s \"$GIT_DIR/BISECT_START\"\n \t\tthen\n-\t\t\t(\n-\t\t\t\tgettext \"You need to give me at least one good and one bad revisions.\n-(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+\t\t\tgettextln \"You need to give me at least one good and one bad revisions.\n+(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" >&2\n \t\telse\n-\t\t\t(\n-\t\t\t\tgettext \"You need to start by \\\"git bisect start\\\".\n+\t\t\tgettextln \"You need to start by \\\"git bisect start\\\".\n You then need to give me at least one good and one bad revisions.\n-(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" >&2\n \t\tfi\n \t\texit 1 ;;\n \tesac\n@@ -351,7 +339,7 @@ bisect_visualize() {\n \n bisect_reset() {\n \ttest -s \"$GIT_DIR/BISECT_START\" || {\n-\t\tgettext \"We are not bisecting.\"; echo\n+\t\tgettextln \"We are not bisecting.\"\n \t\treturn\n \t}\n \tcase \"$#\" in\n@@ -424,18 +412,15 @@ bisect_run () {\n \twhile true\n \tdo\n \t\tcommand=\"$@\"\n-\t\teval_gettext \"running \\$command\"; echo\n+\t\teval_gettextln \"running \\$command\"\n \t\t\"$@\"\n \t\tres=$?\n \n \t\t# Check for really bad run error.\n \t\tif [ $res -lt 0 -o $res -ge 128 ]\n \t\tthen\n-\t\t\t(\n-\t\t\t\teval_gettext \"bisect run failed:\n-exit code \\$res from '\\$command' is < 0 or >= 128\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+\t\t\teval_gettextln \"bisect run failed:\n+exit code \\$res from '\\$command' is < 0 or >= 128\" >&2\n \t\t\texit $res\n \t\tfi\n \n@@ -460,26 +445,20 @@ exit code \\$res from '\\$command' is < 0 or >= 128\" &&\n \t\tif sane_grep \"first bad commit could be any of\" \"$GIT_DIR/BISECT_RUN\" \\\n \t\t\t> /dev/null\n \t\tthen\n-\t\t\t(\n-\t\t\t\tgettext \"bisect run cannot continue any more\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+\t\t\tgettextln \"bisect run cannot continue any more\" >&2\n \t\t\texit $res\n \t\tfi\n \n \t\tif [ $res -ne 0 ]\n \t\tthen\n-\t\t\t(\n-\t\t\t\teval_gettext \"bisect run failed:\n-'bisect_state \\$state' exited with error code \\$res\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+\t\t\teval_gettextln \"bisect run failed:\n+'bisect_state \\$state' exited with error code \\$res\" >&2\n \t\t\texit $res\n \t\tfi\n \n \t\tif sane_grep \"is the first bad commit\" \"$GIT_DIR/BISECT_RUN\" > /dev/null\n \t\tthen\n-\t\t\tgettext \"bisect run success\"; echo\n+\t\t\tgettextln \"bisect run success\"\n \t\t\texit 0;\n \t\tfi\n \ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 32ca59d..e672366 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -11,19 +11,38 @@ then\n \t\tprintf \"%s\" \"$1\"\n \t}\n \n+\tgettextln() {\n+\t\tprintf \"%s\\n\" \"$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+\n+\teval_gettextln () {\n+\t\tprintf \"%s\\n\" \"$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 else\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n \n+\tgettextln () {\n+\t\tprintf \"%s\\n\" \"# GETTEXT POISON #\"\n+\t}\n+\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n+\n+\teval_gettextln () {\n+\t\tprintf \"%s\\n\" \"# GETTEXT POISON #\"\n+\t}\n fi\n \n-- \n1.7.6.362.gf0e6\n"},{"id":"173005","messageId":"CAH3AnroSJcJeFmFq-NKfCfGG3PQ2yOzmZ8_RedHbVEvkY_JaRA@mail.gmail.com","threadId":"28031","inReplyTo":"1312604164-19980-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [RFC] gettext: add gettextln, eval_gettextln to encode common idiom","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-06T04:58:40Z","receivedAt":"2011-08-06T04:58:40Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sat, Aug 6, 2011 at 2:16 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>\n> An example of its use in git-bisect.sh is given.\n>\n\nOther scripts which could benefit from such a function are:\n\ngit-am.sh\ngit-pull.sh\ngit-quiltimport.sh\ngit-stash.sh\ngit-submodule.sh\n\njon.\n"},{"id":"173060","messageId":"CACBZZX4c-F3PZfHWH=4OBVDgtouU3kfJ_0WZ-JzG=0uJhpgRfQ@mail.gmail.com","threadId":"28031","inReplyTo":"1312604164-19980-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [RFC] gettext: add gettextln, eval_gettextln to encode common idiom","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-08-06T11:53:12Z","receivedAt":"2011-08-06T11:53:12Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, Aug 6, 2011 at 06:16, Jon Seymour <jon.seymour@gmail.com> wrote:\n\n> This patch introduces two new helper functions, gettextln and eval_gettextln\n> which append a trailing newline to the gettext output.\n\nI like this, I would have done this myself but didn't have time.\n\nAcked-by me\n"}]}