[libvirt] libvirt-guests output

Eric Blake eblake at redhat.com
Tue Dec 14 18:34:01 UTC 2010


On 12/14/2010 10:58 AM, Laurent Léonard wrote:
>>>     New patch 0010-Debianize-libvirt-guests.patch
>>>
>>> +         if ! $configured; then
>>> +-            echo $"Ignoring guests on $uri URI"
>>> ++            echo "Ignoring guests on $uri URI"
>>
>> It might make sense to introduce a function:
>>
>> libvirt_echo() {
>> 	echo $"$@"
>> }
>>
>> So that the lines above become:
>>
>>          if ! $configured; then
>>             libvirt_echo "Ignoring guests on $uri URI"
>>
>> If we get this integrated upstream  we'd only have to patch a single
>> line which might future merging easier. We might even be able to either
>> pick $" or just " by looking at the shell used.
> 
> What about that proposition ?

Certainly it is better to go through a wrapper function, to minimize the
number of places where translation is attempted.  And run-time detection
of which method to use seems easy enough; something like this (minimally
tested):

if (LC_ALL=C; test $"x" = x); then
    libvirt_echo() {
        echo $"$1"
    }
else
    libvirt_echo() {
        gettext "$1"
    }
fi

But there is still the issue of marking translated strings in such a way
that xgettext can find them.  How do other debian-ized init scripts
handle this problem?  Is there something in
$sysconfdir/rc.d/init.d/functions that is already common between distros
to aid in this effort?

Oh, and this is interesting reading[1], since it claims the use of $""
in bash is a security hole.  Instead, the current gettext
recommendations for adding i18n to a shell script are to source the file
gettext.sh, set TEXTDOMAIN and TEXTDOMAINDIR, and use gettext(1) and
friends everywhere in the first place.  But I didn't find out how
xgettext works on shell scripts (if it even can); xgettext -L doesn't
seem to support a shell-like language.  I guess I'll ask for more advice
on the gettext mailing list.

[1] http://www.gnu.org/software/gettext/manual/gettext.html#bash

But if we go with the gettext advice of avoiding $"" altogether, then
there's no need to go through an intermediate function, and we should
instead mark every translated string by using gettext instead of echo.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101214/2001e3d1/attachment-0001.sig>


More information about the libvir-list mailing list