--- 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