git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Buglet in i18n?
Date: Fri, 22 Oct 2010 03:34:50 -0500	[thread overview]
Message-ID: <20101022083450.GA8289@burratino> (raw)
In-Reply-To: <AANLkTimqzmPLCj=JeSGWFcY829gxct9ANGt+CCjB2jy=@mail.gmail.com>

Ævar Arnfjörð Bjarmason wrote:

>         gettext () {
>             printf "%s" "$1"
>         }
> 
>         eval_gettext () {
>             gettext_eval="printf '%s' \"$1\""
>             printf "%s" "`eval \"$gettext_eval\"`"
>         }

This looks wrong.  Consider a simplified example:

	eval_gettext 'foo "bar baz"'

Now eval_gettext is supposed to just interpolate $variable
substitutions, right?  In particular, the quotation marks
ought to be preserved.

But instead, what gets evaluated is:

	printf '%s' "foo "bar baz""

which splits as

	printf '%s' 'foo bar' 'baz'

which is equivalent to

	printf '%s' 'foo bar'
	printf '%s' 'baz'

with output

	foo barbaz

Maybe something like this would do it?

	gettext_eval=$(
		printf '%s\n' "$1" |
		sed '
			s/[`\\"]/\\&/g
			1 s/^/printf "%s" "/
			$ s/$/"/
		'
	) &&
	eval "$gettext_eval"

  reply	other threads:[~2010-10-22  8:38 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 [this message]
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
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=20101022083450.GA8289@burratino \
    --to=jrnieder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    /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).