git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [RFC/PATCH 1/5] gettext: fix bug in git-sh-i18n's eval_gettext() by using envsubst(1)
Date: Mon, 8 Nov 2010 23:39:49 +0100	[thread overview]
Message-ID: <AANLkTimjRwSxkemMffASvHCxK009b1fnvNRs05_T_1DF@mail.gmail.com> (raw)
In-Reply-To: <4CCFCCC8.7080603@viscovery.net>

On Tue, Nov 2, 2010 at 09:33, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 10/31/2010 12:34, schrieb Ævar Arnfjörð Bjarmason:
>> Change eval_gettext(1) in git-sh-i18n.sh to use a modified version of
>> gettext's envsubst(1) program, instead of using a clever (but broken)
>> printf + eval + printf trick.
>>
>> Our previous fallback would incorrectly handle cases where the
>> variable being interpolated contained spaces. E.g.:
>>
>>     cmd="git foo"; eval_gettext "command: \$cmd"
>>
>> Would emit "command: gitfoo", instead of the correct "command: git
>> foo". This happened with a message in git-am.sh that used the $cmdline
>> variable.
>>
>> To work around this, and to improve our variable expansion behavior
>> (eval has security issues) I've imported a stripped-down version of
>> gettext's envsubst(1) program.
>
> Would this help the case mentioned above at all? To pass the value of
> 'cmd' to envsubst, you have to export it. But the code snippet above
> doesn't do that.

Right, I had a major brainfart. GNU gettext.sh actually works like:

    eval_gettext () {
      gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
    }

So I need to re-make this patch to support --variables.

> Wouldn't it be much simpler to dodge variable substitutions in the
> translated string entirely by rewriting such texts as (e.g.)
>
>        gettext_printf "command: %s\n" "$cmd"
>
> and use printf in the implementation. I don't know how compatible you can
> make this with existing gettext implementations, though.

Using named variables is easier to use, and works drop-in with the GNU gettext
way of doing things. Once I implement --variables (or rather,
un-un-implement them)
it'll just work.

Thanks for the review, and for spotting this sillyness.

  reply	other threads:[~2010-11-08 22:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  7:18 Buglet in i18n? Johannes Sixt
2010-10-22  8:20 ` Ævar Arnfjörð Bjarmason
2010-10-22  8:34   ` Jonathan Nieder
2010-10-23 11:32     ` Ævar Arnfjörð Bjarmason
     [not found]       ` <20101023182940.GD21040@burratino>
2010-10-30  9:14         ` Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 0/5] ab/i18n: Things I'll add in the next iteration Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 1/5] gettext: fix bug in git-sh-i18n's eval_gettext() by using envsubst(1) Ævar Arnfjörð Bjarmason
2010-11-02  8:33             ` Johannes Sixt
2010-11-08 22:39               ` Ævar Arnfjörð Bjarmason [this message]
2010-11-09  7:33                 ` Johannes Sixt
2010-11-09  9:35                   ` Ævar Arnfjörð Bjarmason
2010-11-09  9:47                     ` Johannes Sixt
2010-11-09  9:49                       ` Ævar Arnfjörð Bjarmason
2010-11-09 10:36                         ` Johannes Sixt
2010-11-09 10:38                           ` Erik Faye-Lund
2010-11-09 10:52                           ` Ævar Arnfjörð Bjarmason
2010-11-09 11:42                             ` Johannes Sixt
2010-11-09 11:57                               ` Ævar Arnfjörð Bjarmason
2010-11-09 12:22                                 ` Johannes Sixt
2010-11-09 12:38                                   ` Ævar Arnfjörð Bjarmason
2010-11-09 12:53                                     ` Johannes Sixt
2010-11-09 13:02                                       ` Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 2/5] gettextize: git-clone: !fixup "basic messages" Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 3/5] gettextize: git-init: " Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 4/5] gettextize: git-revert: !fixup "Your local changes" Ævar Arnfjörð Bjarmason
2010-10-31 11:34           ` [RFC/PATCH 5/5] gettextize: git-merge: !fixup "basic messages" Ævar Arnfjörð Bjarmason
2010-10-22  8:49   ` Buglet in i18n? Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimjRwSxkemMffASvHCxK009b1fnvNRs05_T_1DF@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).