From: Bruno Haible Date: Mon, 19 Dec 2005 12:37:56 +0000 (+0000) Subject: Workaround against zsh problem. X-Git-Tag: v0.15~332 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e59c7f764b93527051a68cf2f47266c3dad03e08;p=thirdparty%2Fgettext.git Workaround against zsh problem. --- diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog index 720f2dc87..cc3582144 100644 --- a/gettext-runtime/src/ChangeLog +++ b/gettext-runtime/src/ChangeLog @@ -1,3 +1,7 @@ +2005-12-19 Bruno Haible + + * gettext.sh.in: Make it work when sourced by zsh. + 2005-05-23 Bruno Haible * gettext-0.14.5 released. diff --git a/gettext-runtime/src/gettext.sh.in b/gettext-runtime/src/gettext.sh.in index 75d3f69aa..1e1a2c728 100644 --- a/gettext-runtime/src/gettext.sh.in +++ b/gettext-runtime/src/gettext.sh.in @@ -39,40 +39,47 @@ fi # $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 - gettext.sh | */gettext.sh | *\gettext.sh) - progname=$0 - package=@PACKAGE@ - version=@VERSION@ - # func_usage - # outputs to stdout the --help usage message. - func_usage () - { - echo "GNU gettext shell script function library version $version" - echo "Usage: . gettext.sh" - } - # func_version - # outputs to stdout the --version message. - func_version () - { - echo "$progname (GNU $package) $version" - echo "Copyright (C) 2003-2005 Free Software Foundation, Inc. +if test -z "$ZSH_VERSION"; then + # zsh is not POSIX compliant: By default, while ". gettext.sh" is executed, + # it sets $0 to "gettext.sh", defeating the purpose of this test. But + # fortunately we know that when running under zsh, this script is always + # being sourced, not executed, because hardly anyone is crazy enough to + # install zsh as /bin/sh. + case "$0" in + gettext.sh | */gettext.sh | *\gettext.sh) + progname=$0 + package=@PACKAGE@ + version=@VERSION@ + # func_usage + # outputs to stdout the --help usage message. + func_usage () + { + echo "GNU gettext shell script function library version $version" + echo "Usage: . gettext.sh" + } + # func_version + # outputs to stdout the --version message. + func_version () + { + echo "$progname (GNU $package) $version" + echo "Copyright (C) 2003-2005 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." - echo "Written by" "Bruno Haible" - } - if test $# = 1; then - case "$1" in - --help | --hel | --he | --h ) - func_usage; exit 0 ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version; exit 0 ;; - esac - fi - func_usage 1>&2 - exit 1 - ;; -esac + echo "Written by" "Bruno Haible" + } + if test $# = 1; then + case "$1" in + --help | --hel | --he | --h ) + func_usage; exit 0 ;; + --version | --versio | --versi | --vers | --ver | --ve | --v ) + func_version; exit 0 ;; + esac + fi + func_usage 1>&2 + exit 1 + ;; + esac +fi # eval_gettext MSGID # looks up the translation of MSGID and substitutes shell variables in the