[PATCH 2/2] ldd: Don't use Bash-only $"msgid" quoting

Dmitry V. Levin ldv@altlinux.org
Fri Nov 23 20:02:00 GMT 2012


On Fri, Nov 23, 2012 at 01:23:14PM -0500, P. J. McDermott wrote:
[...]
> Well here's a patch that makes ldd use gettext.sh if found and otherwise
> define simple gettext and eval_gettext functions.  Though these
> functions should probably be defined more globally for use in other
> scripts in glibc.
> 
> Comments/improvements?
[...]
> -TEXTDOMAIN=libc
> -TEXTDOMAINDIR=@TEXTDOMAINDIR@
> +export TEXTDOMAIN=libc
> +export TEXTDOMAINDIR=@TEXTDOMAINDIR@

One may note that this syntax is not quite portable.  Another issue
with exported variables is that they leak to processes being traced.

> +if (. 2>/dev/null gettext.sh); then
> +  . gettext.sh
> +else
> +  # No internationalization available; just print the original strings.
> +  gettext ()
> +  {
> +    printf '%s' "$1"
> +  }

I suggest making this more robust by defining our default gettext()
unconditionally and letting gettext.sh override it.

> +  eval_gettext ()
> +  {

Are you sure we really have to use that ugly eval_gettext?
Wouldn't it be better to change the code to use simpler forms?
The only affected piece in ldd is this one:

> -    echo >&2 $"ldd: option \`$1' is ambiguous"
> +    echo >&2 "$(eval_gettext "ldd: option \`\$1' is ambiguous")"

Let's transform original
echo >&2 $"ldd: option \`$1' is ambiguous"
to
printf >&2 $"ldd: option \`%s' is ambiguous\n" "$1"
so that it could be later changed e.g. to
printf >&2 "$(gettext "ldd: option \`%s' is ambiguous\n")" "$1"


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20121123/82650696/attachment.sig>


More information about the Libc-alpha mailing list