]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support for internationalized shell scripts.
authorBruno Haible <bruno@clisp.org>
Wed, 17 Sep 2003 08:25:06 +0000 (08:25 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:59 +0000 (12:10 +0200)
13 files changed:
ChangeLog
NEWS
PACKAGING
gettext-runtime/NEWS
gettext-runtime/man/ChangeLog
gettext-runtime/man/Makefile.am
gettext-runtime/src/ChangeLog
gettext-runtime/src/Makefile.am
gettext-runtime/src/Makefile.msvc
gettext-runtime/src/Makefile.vms
gettext-tools/tests/ChangeLog
gettext-tools/tests/lang-bash
gettext-tools/tests/lang-sh

index d8a2fab79e677e462633be808d92af44b69646d0..73516171992d1403de099638ac2f3582e663bbff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-13  Bruno Haible  <bruno@clisp.org>
+
+       * PACKAGING: Add envsubst related files and gettext.sh.
+
 2003-08-23  Bruno Haible  <bruno@clisp.org>
 
        * version.sh: Bump version number to 0.12.2.
diff --git a/NEWS b/NEWS
index 0d6e13c8e86f4edd05241a383e510d425fb0f37a..06fa7dcd839b8b2498eb3f97897675b3634a2a5d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,15 @@
-Version 0.12.2 - August 2003
+Version 0.12.2 - September 2003
 
 * Programming languages support:
 
   - Shell:
     xgettext now also supports shell scripts. It recognizes invocations of
-    the programs 'gettext' and 'ngettext' as well as the GNU bash builtin
-    syntax $"...".
+    the programs 'gettext', 'ngettext', the functions 'eval_gettext',
+    'eval_ngettext', as well as the deprecated GNU bash builtin syntax $"...".
+    New function library:
+      gettext.sh - shell functions for internationalized shell scripts.
+    New program:
+      envsubst - substitutes environment variables in shell format strings.
 
   - Perl:
     xgettext now also supports Perl.
index 9a53831f2f1ac7f8eb2ebd31acabc0c1fd68d7be..1766dc3f4c0620ef1c3892bc3b1d61dcf9311267 100644 (file)
--- a/PACKAGING
+++ b/PACKAGING
@@ -50,10 +50,14 @@ following file list.
 
       $prefix/bin/gettext
       $prefix/bin/ngettext
+      $prefix/bin/envsubst
+      $prefix/bin/gettext.sh
       $prefix/share/man/man1/gettext.1
       $prefix/share/man/man1/ngettext.1
+      $prefix/share/man/man1/envsubst.1
       $prefix/share/doc/gettext/gettext.1.html
       $prefix/share/doc/gettext/ngettext.1.html
+      $prefix/share/doc/gettext/envsubst.1.html
       $prefix/share/locale/*/LC_MESSAGES/gettext-runtime.mo
 
       $prefix/lib/libintl.*               (not installed on glibc systems)
index b96d478f4d0060ac58a95695d72bb242c2f3a48f..7987c8cc9aa52961d5af1785911457cf3ab15f0e 100644 (file)
@@ -1,8 +1,13 @@
-Version 0.12.2 - August 2003
+Version 0.12.2 - September 2003
 
 * On those few platforms (NetBSD and Woe32) for which the native
   printf()/fprintf()/... functions don't support POSIX/XSI format strings
   with positions, replacements are provided through <libintl.h>.
+
+* New function library:
+    gettext.sh - shell functions for internationalized shell scripts
+* New program:
+    envsubst - substitutes environment variables in shell format strings
 \f
 Version 0.12 - May 2003
 
index 8db20cc87cf5defe4dafb9aac779ded71865cf65..b620b8567c6e5ea8d8cff7b3ee3d16cbab214796 100644 (file)
@@ -1,3 +1,14 @@
+2003-09-13  Bruno Haible  <bruno@clisp.org>
+
+       * envsubst.x: New file.
+       * Makefile.am (man_aux): Add envsubst.x.
+       (man_MAN1OTHER): New variable.
+       (man_MAN1): Add $(man_MAN1OTHER).
+       (man_HTMLOTHER): Add envsubst.1.html.
+       (EXTRA_DIST, MAINTAINERCLEANFILES): Add $(man_MAN1OTHER).
+       (envsubst.1): New rule.
+       (envsubst.1.html): New rule.
+
 2003-05-22  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.12.1 released.
index c7e9f832d0367c8ad9de7c37646d2ba4a46ec73b..8bbcdd2fb40869459902c23aaeed1c053c94ac74 100644 (file)
@@ -29,13 +29,14 @@ EXTRA_DIST =
 
 # A manual page for each of the bin_PROGRAMS in src/Makefile.am.
 
-man_aux = gettext.x ngettext.x
+man_aux = gettext.x ngettext.x envsubst.x
 
 # Likewise, plus additional manual pages for the libintl functions.
 
 man_MAN1GEN = gettext.1 ngettext.1
 man_MAN1IN = gettext.1.in ngettext.1.in
-man_MAN1 = $(man_MAN1GEN)
+man_MAN1OTHER = envsubst.1
+man_MAN1 = $(man_MAN1GEN) $(man_MAN1OTHER)
 man_MAN3 = gettext.3 ngettext.3 \
 textdomain.3 bindtextdomain.3 bind_textdomain_codeset.3
 man_MAN3IN = gettext.3.in ngettext.3.in \
@@ -46,13 +47,14 @@ man_MANS = $(man_MAN1) $(man_MAN3) $(man_MAN3LINK)
 man_HTMLGEN = gettext.1.html ngettext.1.html
 man_HTMLIN = gettext.1.html.in ngettext.1.html.in
 man_HTMLOTHER = \
+envsubst.1.html \
 gettext.3.html ngettext.3.html \
 textdomain.3.html bindtextdomain.3.html bind_textdomain_codeset.3.html
 man_HTML = $(man_HTMLGEN) $(man_HTMLOTHER)
 
-EXTRA_DIST += help2man $(man_aux) $(man_MAN1IN) $(man_MAN3) $(man_MAN3IN) $(man_MAN3LINK) $(man_HTMLIN) $(man_HTMLOTHER)
+EXTRA_DIST += help2man $(man_aux) $(man_MAN1IN) $(man_MAN1OTHER) $(man_MAN3) $(man_MAN3IN) $(man_MAN3LINK) $(man_HTMLIN) $(man_HTMLOTHER)
 CLEANFILES = $(man_MAN1GEN) $(man_HTMLGEN)
-MAINTAINERCLEANFILES = $(man_MAN1IN) $(man_MAN3) $(man_HTMLIN) $(man_HTMLOTHER)
+MAINTAINERCLEANFILES = $(man_MAN1IN) $(man_MAN1OTHER) $(man_MAN3) $(man_HTMLIN) $(man_HTMLOTHER)
 
 PERL = @PERL@
 RM = rm -f
@@ -92,6 +94,9 @@ gettext.1.in: gettext.x
 ngettext.1.in: ngettext.x
        IN_HELP2MAN=1 $(SHELL) x-to-1 "$(PERL)" "$(HELP2MAN)" ../src/ngettext$(EXEEXT) $(srcdir)/ngettext.x ngettext.1.in
 
+envsubst.1: envsubst.x
+       $(SHELL) x-to-1 "$(PERL)" "$(HELP2MAN)" ../src/envsubst$(EXEEXT) $(srcdir)/envsubst.x envsubst.1
+
 # Depend on version.sh to get version number changes.
 $(man_MAN1): help2man $(top_srcdir)/../version.sh
 
@@ -130,6 +135,10 @@ ngettext.1.html.in: ngettext.1.in
        $(MAN2HTML) `if test -f ngettext.1.in; then echo .; else echo $(srcdir); fi`/ngettext.1.in | sed -e '/CreationDate:/d' > t-$@
        mv t-$@ $@
 
+envsubst.1.html: envsubst.1
+       $(MAN2HTML) `if test -f envsubst.1; then echo .; else echo $(srcdir); fi`/envsubst.1 | sed -e '/CreationDate:/d' > t-$@
+       mv t-$@ $@
+
 gettext.3.html: gettext.3.in
        $(MAN2HTML) $(srcdir)/gettext.3.in | sed -e '/CreationDate:/d' > t-$@
        mv t-$@ $@
index aa834ed0588070a3bf60d1badd452f960c85dfcb..e31e0f6ad6c13bc86d456ed649fb847fdd643163 100644 (file)
@@ -1,3 +1,22 @@
+2003-09-13  Bruno Haible  <bruno@clisp.org>
+
+       * envsubst.c: New file.
+       * gettext.sh: New file.
+       * Makefile.am (bin_PROGRAMS): Add envsubst.
+       (envsubst_SOURCES, envsubst_CFLAGS, envsubst_LDFLAGS): New variables.
+       (all-local): Depend on gettext.sh.
+       (install-data-local, uninstall-local): New rules, for gettext.sh.
+       * Makefile.msvc (PROGRAMS): Add envsubst.exe.
+       (envsubst_OBJECTS): New variable.
+       (envsubst.obj, envsubst.exe): New rules.
+       (install): Install also envsubst.exe and gettext.sh.
+       (uninstall): Uninstall also envsubst.exe and gettext.sh.
+       * Makefile.vms (PROGRAMS): Add envsubst.exe.
+       (envsubst_OBJECTS): New variable.
+       (envsubst.obj, envsubst.exe): New rules.
+       (install): Install also envsubst.exe and gettext.sh.
+       (uninstall): Uninstall also envsubst.exe and gettext.sh.
+
 2003-09-13  Bruno Haible  <bruno@clisp.org>
 
        Fix behaviour of "<program> --help > /dev/full".
index ba93e20a1fbe222a9c27f0618f3ab84bbdc18468..164915e1ee3c6d2e795920938998296e3121cf0f 100644 (file)
@@ -20,7 +20,7 @@
 AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
 EXTRA_DIST =
 
-bin_PROGRAMS = gettext ngettext
+bin_PROGRAMS = gettext ngettext envsubst
 
 localedir = $(datadir)/locale
 
@@ -35,6 +35,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
 # Source dependencies.
 gettext_SOURCES = gettext.c
 ngettext_SOURCES = ngettext.c
+envsubst_SOURCES = envsubst.c
 
 # Link dependencies.
 LDADD = ../lib/libgrt.a @LTLIBINTL@
@@ -42,11 +43,22 @@ LDADD = ../lib/libgrt.a @LTLIBINTL@
 # Specify installation directory, for --enable-relocatable.
 gettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\"
 ngettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\"
+envsubst_CFLAGS = -DINSTALLDIR=\"$(bindir)\"
 if RELOCATABLE_VIA_LD
 gettext_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)`
 ngettext_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)`
+envsubst_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)`
 endif
 
+# Special rule for installing gettext.sh in $(bindir).
+# automake doesn't handle "bin_DATA = gettext.sh".
+all-local: gettext.sh
+install-data-local: all-local
+       $(mkinstalldirs) $(DESTDIR)$(bindir)
+       $(INSTALL_DATA) $(srcdir)/gettext.sh $(DESTDIR)$(bindir)/gettext.sh
+uninstall-local: all-local
+       $(RM) $(DESTDIR)$(bindir)/gettext.sh
+
 # Support for relocatability.
 RELOCATABLE_LIBRARY_PATH = $(libdir)
 RELOCATABLE_SRC_DIR = $(top_srcdir)/../gettext-tools/lib
index f8e0342742c0ef9c5b909ebb4952e9f10b945334..a74d34dee7c5ee99fcb599c1197b394cd8d6d65e 100644 (file)
@@ -87,10 +87,11 @@ INSTALL_DATA = copy
 
 SHELL = /bin/sh
 
-PROGRAMS = gettext.exe ngettext.exe
+PROGRAMS = gettext.exe ngettext.exe envsubst.exe
 
 gettext_OBJECTS = gettext.obj
 ngettext_OBJECTS = ngettext.obj
+envsubst_OBJECTS = envsubst.obj
 LDADD =
 
 all : $(PROGRAMS)
@@ -101,18 +102,26 @@ gettext.obj : gettext.c
 ngettext.obj : ngettext.c
        $(CC) $(INCLUDES) $(CFLAGS) -DINSTALLPREFIX=\"$(IIprefix)\" -DINSTALLDIR=\"$(IIbindir)\" -c ngettext.c
 
+envsubst.obj : envsubst.c
+       $(CC) $(INCLUDES) $(CFLAGS) -DINSTALLPREFIX=\"$(IIprefix)\" -DINSTALLDIR=\"$(IIbindir)\" -c envsubst.c
+
 gettext.exe : $(gettext_OBJECTS)
        $(CC) $(MFLAGS) $(DEBUGFLAGS) $(gettext_OBJECTS) ..\lib\grt.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Fegettext.exe
 
 ngettext.exe : $(ngettext_OBJECTS)
        $(CC) $(MFLAGS) $(DEBUGFLAGS) $(ngettext_OBJECTS) ..\lib\grt.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Fengettext.exe
 
+envsubst.exe : $(envsubst_OBJECTS)
+       $(CC) $(MFLAGS) $(DEBUGFLAGS) $(ngettext_OBJECTS) ..\lib\grt.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Feenvsubst.exe
+
 install : all force
        -mkdir $(prefix)
        -mkdir $(exec_prefix)
        -mkdir $(bindir)
        $(INSTALL_PROGRAM) gettext.exe $(bindir)\gettext.exe
        $(INSTALL_PROGRAM) ngettext.exe $(bindir)\ngettext.exe
+       $(INSTALL_PROGRAM) envsubst.exe $(bindir)\envsubst.exe
+       $(INSTALL_DATA) gettext.sh $(bindir)\gettext.sh
 
 installdirs : force
        -mkdir $(prefix)
@@ -122,6 +131,8 @@ installdirs : force
 uninstall : force
        $(RM) $(bindir)\gettext.exe
        $(RM) $(bindir)\ngettext.exe
+       $(RM) $(bindir)\envsubst.exe
+       $(RM) $(bindir)\gettext.sh
 
 check : all
 
index 6623328323cd9e20054e315ae15957cc0c2d209b..c53527bd23694a542b981c33fcdbc9dd374cae25 100644 (file)
@@ -38,10 +38,11 @@ INSTALL_DATA = copy
 
 #### End of system configuration section. ####
 
-PROGRAMS = gettext.exe, ngettext.exe
+PROGRAMS = gettext.exe, ngettext.exe, envsubst.exe
 
 gettext_OBJECTS = gettext.obj
 ngettext_OBJECTS = ngettext.obj
+envsubst_OBJECTS = envsubst.obj
 
 all : $(PROGRAMS)
        write sys$output "Nothing else to be done for 'all'."
@@ -52,6 +53,9 @@ gettext.obj : gettext.c
 ngettext.obj : ngettext.c
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") ngettext.c
 
+envsubst.obj : envsubst.c
+       $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") envsubst.c
+
 libiconv.opt :
        if f$search("sys$library:libiconv.olb") .nes. "" then $(LN) [-.-.vms]with-libiconv.opt libiconv.opt
        if f$search("sys$library:libiconv.olb") .eqs. "" then $(LN) [-.-.vms]without-libiconv.opt libiconv.opt
@@ -62,12 +66,17 @@ gettext.exe : $(gettext_OBJECTS),libiconv.opt
 ngettext.exe : $(ngettext_OBJECTS),libiconv.opt
        link /executable=ngettext.exe $(ngettext_OBJECTS),[-.lib]grt.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
 
+envsubst.exe : $(envsubst_OBJECTS),libiconv.opt
+       link /executable=envsubst.exe $(envsubst_OBJECTS),[-.lib]grt.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
+
 install : all
        create /directory $(prefix)]
        create /directory $(exec_prefix)]
        create /directory $(bindir)]
        $(INSTALL_PROGRAM) gettext.exe $(bindir)]gettext.exe
        $(INSTALL_PROGRAM) ngettext.exe $(bindir)]ngettext.exe
+       $(INSTALL_PROGRAM) envsubst.exe $(bindir)]envsubst.exe
+       $(INSTALL_DATA) gettext.sh $(bindir)]gettext.sh
 
 installdirs :
        create /directory $(prefix)]
@@ -77,6 +86,8 @@ installdirs :
 uninstall :
        $(RM) $(bindir)]gettext.exe;
        $(RM) $(bindir)]ngettext.exe;
+       $(RM) $(bindir)]envsubst.exe;
+       $(RM) $(bindir)]gettext.sh;
 
 check : all
        write sys$output "Nothing else to be done for 'check'."
index 19aa7acc6d9da0453a72d4c92009f0e10ca72896..548b6f0b4a3b724685ef339f752b17a450a8c03f 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-13  Bruno Haible  <bruno@clisp.org>
+
+       * lang-sh: Source gettext.sh.
+       (echo, eval_gettext, eval_ngettext): Remove definitions.
+       * lang-bash: Source gettext.sh.
+       (echo, eval_ngettext): Remove definitions.
+
 2003-09-13  Bruno Haible  <bruno@clisp.org>
 
        * format-sh-1: Update to match stricter format string definition.
index 76459a5868a22566580d7ffb693411e741b47763..b2899dcda0f6331d0251088e18becb25cda2e1cb 100755 (executable)
@@ -11,35 +11,15 @@ tmpfiles="$tmpfiles prog.sh"
 cat <<\EOF > prog.sh
 #! /bin/bash
 
-# Find a way to echo strings without interpreting backslash.
-if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
-  echo='echo'
-else
-  if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
-    echo='printf %s\n'
-  else
-    echo_func () {
-      cat <<EOT
-$*
-EOT
-    }
-    echo='echo_func'
-  fi
-fi
-
 n=$1
 
+. gettext.sh
+
 TEXTDOMAIN=prog
 export TEXTDOMAIN
 TEXTDOMAINDIR=.
 export TEXTDOMAINDIR
 
-eval_ngettext () {
-  _string=`ngettext "$1" "$2" "$3"`
-  eval _string="\"$_string\""
-  $echo "$_string"
-}
-
 $echo $"'Your command, please?', asked the waiter."
 
 $echo "`eval_ngettext "a piece of cake" "\\$n pieces of cake" $n`"
index dd03d9415916abf724e97269ef7037a884569f57..41a1b97b3364f0d39f97b4a7c4bce38e2b570c3a 100755 (executable)
@@ -11,41 +11,15 @@ tmpfiles="$tmpfiles prog.sh"
 cat <<\EOF > prog.sh
 #! /bin/sh
 
-# Find a way to echo strings without interpreting backslash.
-if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
-  echo='echo'
-else
-  if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
-    echo='printf %s\n'
-  else
-    echo_func () {
-      cat <<EOT
-$*
-EOT
-    }
-    echo='echo_func'
-  fi
-fi
-
 n=$1
 
+. gettext.sh
+
 TEXTDOMAIN=prog
 export TEXTDOMAIN
 TEXTDOMAINDIR=.
 export TEXTDOMAINDIR
 
-eval_gettext () {
-  _string=`gettext "$1"`
-  eval _string="\"$_string\""
-  $echo "$_string"
-}
-
-eval_ngettext () {
-  _string=`ngettext "$1" "$2" "$3"`
-  eval _string="\"$_string\""
-  $echo "$_string"
-}
-
 $echo "`gettext \"'Your command, please?', asked the waiter.\"`"
 
 $echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`"
@@ -78,7 +52,7 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
 msgid "'Your command, please?', asked the waiter."
-msgstr "«Votre commande, s'il vous plait», dit le garçon."
+msgstr "Votre commande, s'il vous plait, dit le gar�n."
 
 # Les gateaux allemands sont les meilleurs du monde.
 #, sh-format
@@ -105,7 +79,7 @@ ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
 tmpfiles="$tmpfiles prog.ok prog.out"
 : ${DIFF=diff}
 cat <<\EOF > prog.ok
-«Votre commande, s'il vous plait», dit le garçon.
+Votre commande, s'il vous plait, dit le gar�n.
 2 morceaux de gateau
 EOF