This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/2] ldd: Don't use Bash-only $"msgid" quoting
- From: "P. J. McDermott" <pjm at nac dot net>
- To: libc-alpha at sourceware dot org
- Date: Thu, 22 Nov 2012 22:42:12 -0500
- Subject: [PATCH 2/2] ldd: Don't use Bash-only $"msgid" quoting
- Reply-to: "P. J. McDermott" <pjm at nac dot net>, libc-alpha at sourceware dot org
On non-Bash shells, ldd prints translatable strings in English
(regardless of the environment's locale) and prefixed with dollar signs,
e.g.:
$ export LC_ALL=es_ES.UTF-8
$ /bin/dash /usr/bin/ldd --invalid
ldd: $unrecognized option `--invalid'
$Try `ldd --help' for more information.
This patch makes ldd use the more portable (and secure) gettext utility
and eval_gettext function.
2012-11-22 P. J. McDermott <pjm@nac.net>
* elf/ldd.bash.in: Use gettext utility and eval_gettext function instead
of insecure and unportable Bash $"msgid" quoting.
---
elf/ldd.bash.in | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index 86f47e6..c6a2449 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -23,8 +23,9 @@
# variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
# We should be able to find the translation right at the beginning.
-TEXTDOMAIN=libc
-TEXTDOMAINDIR=@TEXTDOMAINDIR@
+. gettext.sh
+export TEXTDOMAIN=libc
+export TEXTDOMAINDIR=@TEXTDOMAINDIR@
RTLDLIST=@RTLD@
warn=
@@ -35,24 +36,24 @@ while test $# -gt 0; do
case "$1" in
--vers | --versi | --versio | --version)
echo 'ldd @PKGVERSION@@VERSION@'
- printf $"Copyright (C) %s Free Software Foundation, Inc.
+ printf "$(gettext "Copyright (C) %s Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-" "2012"
- printf $"Written by %s and %s.
-" "Roland McGrath" "Ulrich Drepper"
+")" "2012"
+ printf "$(gettext "Written by %s and %s.
+")" "Roland McGrath" "Ulrich Drepper"
exit 0
;;
--h | --he | --hel | --help)
- echo $"Usage: ldd [OPTION]... FILE...
+ echo "$(gettext "Usage: ldd [OPTION]... FILE...
--help print this help and exit
--version print version information and exit
-d, --data-relocs process data relocations
-r, --function-relocs process data and function relocations
-u, --unused print unused direct dependencies
-v, --verbose print all information
-"
- printf $"For bug reporting instructions, please see:\\n%s.\\n" \
+")"
+ printf "$(gettext "For bug reporting instructions, please
see:\\n%s.\\n")" \
"@REPORT_BUGS_TO@"
exit 0
;;
@@ -77,15 +78,15 @@ warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
shift
;;
--v | --ve | --ver)
- echo >&2 $"ldd: option \`$1' is ambiguous"
+ echo >&2 "$(eval_gettext "ldd: option \`\$1' is ambiguous")"
exit 1
;;
--) # Stop option processing.
shift; break
;;
-*)
- echo >&2 'ldd:' $"unrecognized option" "\`$1'"
- echo >&2 $"Try \`ldd --help' for more information."
+ echo >&2 'ldd:' "$(gettext "unrecognized option")" "\`$1'"
+ echo >&2 "$(gettext "Try \`ldd --help' for more information.")"
exit 1
;;
*)
@@ -117,8 +118,8 @@ try_trace() {
case $# in
0)
- echo >&2 'ldd:' $"missing file arguments"
- echo >&2 $"Try \`ldd --help' for more information."
+ echo >&2 'ldd:' "$(gettext "missing file arguments")"
+ echo >&2 "$(gettext "Try \`ldd --help' for more information.")"
exit 1
;;
1)
@@ -140,14 +141,14 @@ for file do
;;
esac
if test ! -e "$file"; then
- echo "ldd: ${file}:" $"No such file or directory" >&2
+ echo "ldd: ${file}:" "$(gettext "No such file or directory")" >&2
result=1
elif test ! -f "$file"; then
- echo "ldd: ${file}:" $"not regular file" >&2
+ echo "ldd: ${file}:" "$(gettext "not regular file")" >&2
result=1
elif test -r "$file"; then
- test -x "$file" || echo 'ldd:' $"\
-warning: you do not have execution permission for" "\`$file'" >&2
+ test -x "$file" || echo 'ldd:' "$(gettext "\
+warning: you do not have execution permission for")" "\`$file'" >&2
RTLD=
ret=1
for rtld in ${RTLDLIST}; do
@@ -175,7 +176,7 @@ warning: you do not have execution permission for"
"\`$file'" >&2
1)
# This can be a non-ELF binary or no binary at all.
nonelf "$file" || {
- echo $" not a dynamic executable"
+ echo "$(gettext " not a dynamic executable")"
result=1
}
;;
@@ -183,12 +184,12 @@ warning: you do not have execution permission for"
"\`$file'" >&2
try_trace "$RTLD" "$file" || result=1
;;
*)
- echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
+ echo 'ldd:' ${RTLD} "$(gettext "exited with unknown exit code")"
"($ret)" >&2
exit 1
;;
esac
else
- echo 'ldd:' $"error: you do not have read permission for"
"\`$file'" >&2
+ echo 'ldd:' "$(gettext "error: you do not have read permission
for")" "\`$file'" >&2
result=1
fi
done
--
1.7.10.4