Re: Buglet in i18n?

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

 



Ã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"
--
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]