Re: Buglet in i18n?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 22, 2010 at 08:34, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
> Ã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

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 :)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]