Buglet in i18n?

5 messages, 3 authors, 2016-06-15 · open the first message on its own page

Buglet in i18n?

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:49:50

I just noticed these message after a 'git am' invocation:

When you have resolved this problem run gitam--resolved.
If you would prefer to skip this patch, instead run gitam--skip.
To restore the original branch and stop patching run gitam--abort.

Notice the missing blanks in the suggested commands.

This is on Windows. I have ab/i18n (a102b434c) merged, but compiled with
NO_GETTEXT.

-- Hannes

Re: Buglet in i18n?

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:50

On Fri, Oct 22, 2010 at 09:18, Johannes Sixt [off-list ref] wrote:
I just noticed these message after a 'git am' invocation:

When you have resolved this problem run gitam--resolved.
If you would prefer to skip this patch, instead run gitam--skip.
To restore the original branch and stop patching run gitam--abort.

Notice the missing blanks in the suggested commands.

This is on Windows. I have ab/i18n (a102b434c) merged, but compiled with
NO_GETTEXT.
This is the message in the code:

    eval_gettext "When you have resolved this problem run \"\$cmdline
--resolved\".
If you would prefer to skip this patch, instead run \"\$cmdline
--skip\".
To restore the original branch and stop patching run \"\$cmdline
--abort\"."; echo

And presumably you're using these functions from git-sh-i18n.sh:

        gettext () {
            printf "%s" "$1"
        }

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

So maybe the shell on Windows doesn't behave the same way wih regards
to eval_gettext()?

Re: Buglet in i18n?

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:50

Æ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"

Re: Buglet in i18n?

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:49:50

Am 10/22/2010 10:20, schrieb Ævar Arnfjörð Bjarmason:
So maybe the shell on Windows doesn't behave the same way wih regards
to eval_gettext()?
It's the gettext fallbacks that do not work. Try this on Linux:

  GIT_INTERNAL_GETTEXT_TEST_FALLBACKS=t ./git-am -3 some-mbox

(with some-mbox that has a conflicting patch).

-- Hannes

Re: Buglet in i18n?

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:51

On Fri, Oct 22, 2010 at 08:34, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
        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
Indeed. It's a bug.
Maybe something like this would do it?

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

    foo "bar baz"

(with double quotes)

But what we want is:

    foo bar baz

But what we're getting is:

    foo barbaz

Have I got that right, sorry, not thinking clearly right now :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help