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

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

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


From: Bob Proulx
Subject: Re: gettext.sh and bash "shopt -o -s nounset"
Date: Thu, 12 May 2011 12:19:41 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Thorsten,

Thorsten Kampe wrote:
> I hope this is the right forum for reporting gettext bugs.

Sorry but for gettext bugs it isn't.  As far as I know the gettext
maintainers are not subscribed to this mailing list and won't see your
message.  (I looked but didn't see anyone on the mailing list address
list.)  The gettext README file says:

  Send comments and bug reports to

                bug-gnu-gettext@gnu.org

For gettext bugs please send your reports there.

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

Well, that is a matter of opinion.  There are programmers who like the
one paradigm and those that like the other paradigm.  Neither is
inherently right or wrong.  It is optionally set either way.

> Using...
> 
>     shopt -o -s errexit nounset
>     source gettext.sh
> 
> ...in a script results in:
> /usr/bin/gettext.sh: line 43: ZSH_VERSION: unbound variable

If it were me I would argue that you are not sourcing the script in a
reasonable environment.  But I don't know what Bruno will say.  You
should report this to bug-gnu-gettext and see.

> ...which refers to the following line in gettext.sh: "if test -z 
> "$ZSH_VERSION"; then".
> 
> if [ x${ZSH_VERSION+set} = xset ]
>     and
> if [ -n "${ZSH_VERSION+x}" ]

That seems perfectly reasonable to me.

> While there is a workaround for this (first sourcing, then setting 
> "nounset"), I'd still consider this a bug. Is this enough to qualify for 
> a bug report?

If I were the maintainer I wouldn't consider this a bug.  There are
many ways that you can break the environment when sourcing a script.
For example you can unset PATH.  For example you can alias shell
reserved words to other things (such as aliasing "if" to something).
A sourced script expects a sane environment.  It isn't really possible
for a sourced script to protect itself against all possible ways for
people to break it.  I personally don't consider nounset to be a sane
environment.

I would look through the gettext usage carefully (I haven't looked at
it for a long time and would need to review it) and see what the
documentation says about the environment used for sourcing that
script.  (If it doesn't say then that would at the least be a
documentation problem that it should document what it expects.)  Then
after having reviewed that then I would send a report to
bug-gnu-gettext@gnu.org with the details.  Note that I am not
associated with the gettext project and this is nothing more than a
3rd party opinion on this topic.

Bob



reply via email to

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