bug-gettext
[Top][All Lists]
Advanced

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

Re: [bug-gettext] gettext.sh and bash "shopt -o -s nounset"


From: Bruno Haible
Subject: Re: [bug-gettext] gettext.sh and bash "shopt -o -s nounset"
Date: Fri, 13 May 2011 03:12:38 +0200
User-agent: KMail/1.9.9

Hi,

> In my bash scripts I set "nounset" (and errexit) to prevent unset 
> variables from being used. Using variables which might not be set is 
> convenient in interactive shell sessions but dangerous in non-
> interactive scripts.
> 
> Using...
> 
>     shopt -o -s errexit nounset
>     source gettext.sh
> 
> ...in a script results in:
> /usr/bin/gettext.sh: line 43: ZSH_VERSION: unbound variable

A shell script function library cannot support all possible shell
options, from '-e' to 'noglob'. But since you are already pointing
to a workaround

> if [ x${ZSH_VERSION+set} = xset ]
>     and
> if [ -n "${ZSH_VERSION+x}" ]

that is easy to apply, I'm applying it.


diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog
index 8c2d8e3..fc46918 100644
--- a/gettext-runtime/src/ChangeLog
+++ b/gettext-runtime/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-12  Bruno Haible  <address@hidden>
+
+       * gettext.sh.in: Avoid reference to unset shell variable ZSH_VERSION.
+       Reported by Thorsten Kampe <address@hidden>.
+
 2010-06-04  Bruno Haible  <address@hidden>
 
        * gettext-0.18.1 released.
diff --git a/gettext-runtime/src/gettext.sh.in 
b/gettext-runtime/src/gettext.sh.in
index 5c2c107..7e415dc 100644
--- a/gettext-runtime/src/gettext.sh.in
+++ b/gettext-runtime/src/gettext.sh.in
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005-2007, 2011 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Library General Public License as published
@@ -40,7 +40,7 @@ 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.
-if test -z "$ZSH_VERSION"; then
+if test -z "${ZSH_VERSION+set}"; 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

-- 
In memoriam Irena Sendler <http://en.wikipedia.org/wiki/Irena_Sendler>



reply via email to

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