bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug#343354: gettext-base: gettext.sh can't be sourced from zsh using the


From: Santiago Vila
Subject: Bug#343354: gettext-base: gettext.sh can't be sourced from zsh using the default zsh options (fwd)
Date: Wed, 14 Dec 2005 17:55:55 +0100 (CET)

Hello.

I received the following report from the Debian bug system:

---------- Forwarded message ----------
From: Sergio Talens-Oliag <address@hidden>
To: Debian Bug Tracking System <address@hidden>
Date: Wed, 14 Dec 2005 17:29:14 +0100
Subject: #343354: gettext-base: gettext.sh can't be sourced from zsh using the
    default zsh options

Package: gettext-base
Version: 0.14.5-2
Severity: normal
Tags: patch

Using zsh with the option FUNCTION_ARGZERO set (the default), the gettext.sh
script can't be sourced.

I'm attaching a simple patch to fix it.

[...]

--- gettext.sh.in.orig  2005-05-20 22:14:33.000000000 +0200
+++ gettext.sh.in       2005-12-14 17:19:13.386571720 +0100
@@ -39,7 +39,20 @@
 # $PREFIX/share/sh-scripts or $PREFIX/share/gettext. In order to not violate
 # the Filesystem Hierarchy Standard when doing so, this script is executable.
 # Therefore it needs to support the standard --help and --version.
-case "$0" in
+#
+# To detect if the script has been called directly we define a test function.
+# We do it this way to be able to source the script from zsh, as this shell
+# replaces the $0 variable for sourced scripts and functions by default (this
+# behaviour is controlled using the option FUNCTION_ARGZERO); by using a
+# function we are sure that if FUNCTION_ARGZERO is set, $0 never takes the
+# program name, while the program works as expected when $0 is not replaced.
+# Note that using this method if we execute the script using zsh with the
+# default options we will not see the --help or --version messages, but that
+# is not important, as the executable script is run using '/bin/sh' and we get
+# the desired efect when it is called directly.
+
+gettext_sh_fhs_test() {
+  case "$0" in
   gettext.sh | */gettext.sh | *\gettext.sh)
     progname=$0
     address@hidden@
@@ -72,7 +85,11 @@
     func_usage 1>&2
     exit 1
     ;;
-esac
+  esac
+}
+
+# Test if we have been called as a script
+gettext_sh_fhs_test $@
 
 # eval_gettext MSGID
 # looks up the translation of MSGID and substitutes shell variables in the




reply via email to

[Prev in Thread] Current Thread [Next in Thread]