This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2b 1/2][BZ #13853] Use printf for all translatable output


2012-11-25  P. J. McDermott  <pj@nac.net>

	* elf/ldd.bash.in: Use printf instead of echo for all translatable
	output.
	* elf/sotruss.ksh: Likewise.
	* malloc/memusage.sh: Likewise.

	* debug/xtrace.sh: Add script and year variables.
	* elf/ldd.bash.in: Likewise.
	* elf/sotruss.ksh: Likewise.
	* malloc/memusage.sh: Likewise.
---
 debug/xtrace.sh    |   14 ++++++++------
 elf/ldd.bash.in    |   31 +++++++++++++++++--------------
 elf/sotruss.ksh    |   23 +++++++++++++----------
 malloc/memusage.sh |   20 +++++++++++---------
 4 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/debug/xtrace.sh b/debug/xtrace.sh
index ec1cd09..943d0f8 100755
--- a/debug/xtrace.sh
+++ b/debug/xtrace.sh
@@ -20,6 +20,8 @@
 pcprofileso='@SLIBDIR@/libpcprofile.so'
 pcprofiledump='@BINDIR@/pcprofiledump'
 TEXTDOMAIN=libc
+script="xtrace"
+year="2012"
 
 # Print usage message.
 do_usage() {
@@ -29,13 +31,13 @@ do_usage() {
 
 # Refer to --help option.
 help_info() {
-  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" xtrace xtrace
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" "$script" "$script"
   exit 1
 }
 
 # Message for missing argument.
 do_missing_arg() {
-  printf >&2 $"%s: option '%s' requires an argument.\n" xtrace "$1"
+  printf >&2 $"%s: option '%s' requires an argument.\n" "$script" "$1"
   help_info
 }
 
@@ -64,7 +66,7 @@ do_version() {
   printf $"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"
+" "$year"
   printf $"Written by %s.
 " "Ulrich Drepper"
   exit 0
@@ -122,7 +124,7 @@ while test $# -gt 0; do
     break
     ;;
   --*)
-    printf >&2 $"xtrace: unrecognized option \`$1'\n"
+    printf >&2 $"%s: unrecognized option \`%s'\n" "$script" "$1"
     help_info
     ;;
   *)
@@ -143,11 +145,11 @@ fi
 program=$1
 shift
 if test ! -f "$program"; then
-  printf >&2 $"executable \`$program' not found\n"
+  printf >&2 $"executable \`%s' not found\n" "$program"
   help_info
 fi
 if test ! -x "$program"; then
-  printf >&2 $"\`$program' is no executable\n"
+  printf >&2 $"\`%s' is no executable\n" "$program"
   help_info
 fi
 
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index ff4714d..5e5a626 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -30,6 +30,8 @@ RTLDLIST=@RTLD@
 warn=
 bind_now=
 verbose=
+script="ldd"
+year="2012"
 
 while test $# -gt 0; do
   case "$1" in
@@ -38,19 +40,20 @@ while test $# -gt 0; do
     printf $"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"
+" "$year"
     printf $"Written by %s and %s.
 " "Roland McGrath" "Ulrich Drepper"
     exit 0
     ;;
   --h | --he | --hel | --help)
-    echo $"Usage: ldd [OPTION]... FILE...
+    printf $"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" \
       "@REPORT_BUGS_TO@"
@@ -77,15 +80,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     shift
     ;;
   --v | --ve | --ver)
-    echo >&2 $"ldd: option \`$1' is ambiguous"
+    printf >&2 $"%s: option \`%s' is ambiguous\n" "$script" "$1"
     exit 1
     ;;
   --)		# Stop option processing.
     shift; break
     ;;
   -*)
-    echo >&2 'ldd:' $"unrecognized option" "\`$1'"
-    echo >&2 $"Try \`ldd --help' for more information."
+    printf >&2 $"%s: unrecognized option \`%s'\n" "$script" "$1"
+    printf >&2 $"Try \`%s --help' for more information.\n" "$script"
     exit 1
     ;;
   *)
@@ -122,8 +125,8 @@ fi
 
 case $# in
 0)
-  echo >&2 'ldd:' $"missing file arguments"
-  echo >&2 $"Try \`ldd --help' for more information."
+  printf >&2 $"%s: missing file arguments\n" "$script"
+  printf >&2 $"Try \`%s --help' for more information.\n" "$script"
   exit 1
   ;;
 1)
@@ -145,14 +148,14 @@ for file do
      ;;
   esac
   if test ! -e "$file"; then
-    echo "ldd: ${file}:" $"No such file or directory" >&2
+    printf $"%s: %s: No such file or directory\n" "$script" "$file" >&2
     result=1
   elif test ! -f "$file"; then
-    echo "ldd: ${file}:" $"not regular file" >&2
+    printf $"%s: %s: not regular file\n" "$script" "$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" || printf $"%s: \
+warning: you do not have execution permission for \`%s'\n" "$script" "$file" >&2
     RTLD=
     ret=1
     for rtld in ${RTLDLIST}; do
@@ -180,7 +183,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"
+	printf $"	not a dynamic executable\n"
 	result=1
       }
       ;;
@@ -188,12 +191,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
+      printf $"%s: %s exited with unknown exit code (%d)\n" "$script" "$RTLD" $ret >&2
       exit 1
       ;;
     esac
   else
-    echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
+    printf $"%s: error: you do not have read permission for \`%s'\n" "$script" "$file" >&2
     result=1
   fi
 done
diff --git a/elf/sotruss.ksh b/elf/sotruss.ksh
index 587ab68..afbecbd 100755
--- a/elf/sotruss.ksh
+++ b/elf/sotruss.ksh
@@ -27,9 +27,11 @@ unset SOTRUSS_EXIT
 unset SOTRUSS_NOINDENT
 SOTRUSS_WHICH=$$
 lib='@PREFIX@/$LIB/audit/sotruss-lib.so'
+script="sotruss"
+year="2012"
 
 function do_help {
-  echo $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
+  printf $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
   -F, --from FROMLIST     Trace calls from objects on FROMLIST
   -T, --to TOLIST         Trace calls to objects on TOLIST
 
@@ -40,9 +42,10 @@ function do_help {
 
   -?, --help              Give this help list
       --usage             Give a short usage message
-      --version           Print program version"
+      --version           Print program version
+
+"
 
-  echo
   printf $"Mandatory arguments to long options are also mandatory for any corresponding\nshort options.\n"
   echo
 
@@ -52,8 +55,8 @@ function do_help {
 }
 
 function do_missing_arg {
-  printf >&2 $"%s: option requires an argument -- '%s'\n" sotruss "$1"
-  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+  printf >&2 $"%s: option requires an argument -- '%s'\n" "$script" "$1"
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" "$script" "$script"
   exit 1
 }
 
@@ -64,7 +67,7 @@ function do_ambiguous {
     shift
   done
   printf >&2 "\n"
-  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" "$script" "$script"
   exit 1
 }
 
@@ -75,7 +78,7 @@ while test $# -gt 0; do
     printf $"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"
+" "$year"
     printf $"Written by %s.\n" "Ulrich Drepper"
     exit 0
     ;;
@@ -86,7 +89,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     printf $"Usage: %s [-ef] [-F FROMLIST] [-o FILENAME] [-T TOLIST] [--exit]
 	    [--follow] [--from FROMLIST] [--output FILENAME] [--to TOLIST]
 	    [--help] [--usage] [--version] [--]
-	    EXECUTABLE [EXECUTABLE-OPTION...]\n" sotruss
+	    EXECUTABLE [EXECUTABLE-OPTION...]\n" "$script"
     exit 0
     ;;
   -F | --fr | --fro | --from)
@@ -131,8 +134,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     break
     ;;
   -*)
-    printf >&2 $"%s: unrecognized option '%c%s'\n" sotruss '-' ${1#-}
-    printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+    printf >&2 $"%s: unrecognized option '%c%s'\n" "$script" '-' ${1#-}
+    printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" "$script" "$script"
     exit 1
     ;;
   *)
diff --git a/malloc/memusage.sh b/malloc/memusage.sh
index 50b92d5..2a722a1 100755
--- a/malloc/memusage.sh
+++ b/malloc/memusage.sh
@@ -20,22 +20,24 @@
 memusageso='@SLIBDIR@/libmemusage.so'
 memusagestat='@BINDIR@/memusagestat'
 TEXTDOMAIN=libc
+script="memusage"
+year="2012"
 
 # Print usage message.
 do_usage() {
-  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" memusage memusage
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" "$script" "$script"
   exit 1
 }
 
 # Message for missing argument.
 do_missing_arg() {
-  printf >&2 $"%s: option '%s' requires an argument\n" memusage "$1"
+  printf >&2 $"%s: option '%s' requires an argument\n" "$script" "$1"
   do_usage
 }
 
 # Print help message
 do_help() {
-  echo $"Usage: memusage [OPTION]... PROGRAM [PROGRAMOPTION]...
+  printf $"Usage: memusage [OPTION]... PROGRAM [PROGRAMOPTION]...
 Profile memory usage of PROGRAM.
 
    -n,--progname=NAME     Name of the program file to profile
@@ -71,7 +73,7 @@ do_version() {
   printf $"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"
+" "$year"
   printf $"Written by %s.
 " "Ulrich Drepper"
   exit 0
@@ -96,10 +98,10 @@ while test $# -gt 0; do
     do_help
     ;;
   --us | --usa | --usag | --usage)
-    echo $"Syntax: memusage [--data=FILE] [--progname=NAME] [--png=FILE] [--unbuffered]
+    printf $"Syntax: memusage [--data=FILE] [--progname=NAME] [--png=FILE] [--unbuffered]
 	    [--buffer=SIZE] [--no-timer] [--time-based] [--total]
 	    [--title=STRING] [--x-size=SIZE] [--y-size=SIZE]
-	    PROGRAM [PROGRAMOPTION]..."
+	    PROGRAM [PROGRAMOPTION]...\n"
     exit 0
     ;;
   -n | --pr | --pro | --prog | --progn | --progna | --prognam | --progname)
@@ -188,7 +190,7 @@ while test $# -gt 0; do
     memusagestat_args="$memusagestat_args -y ${1##*=}"
     ;;
   --p | --p=* | --t | --t=* | --ti | --ti=* | --u)
-    echo >&2 $"memusage: option \`${1##*=}' is ambiguous"
+    printf >&2 $"%s: option \`%s' is ambiguous\n" "$script" "${1##*=}"
     do_usage
     ;;
   --)
@@ -197,7 +199,7 @@ while test $# -gt 0; do
     break
     ;;
   --*)
-    echo >&2 $"memusage: unrecognized option \`$1'"
+    printf >&2 $"%s: unrecognized option \`%s'\n" "$script" "$1"
     do_usage
     ;;
   *)
@@ -210,7 +212,7 @@ done
 
 # See whether any arguments are left.
 if test $# -eq 0; then
-  echo >&2 $"No program name given"
+  printf >&2 $"No program name given\n"
   do_usage
 fi
 
-- 
1.7.10.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]