Re: [PATCH] Update bash completions to prevent unbound variable errors.
- From
Adeodato Simó <dato@net.com.org.es>
- Date
- Jan 12, 2009, 21:25 UTC
- Message-ID
- <20090112212544.GA24941@chistera.yi.org>
- In-Reply-To
- <496BB204.2040109@tedpavlic.com>
* Ted Pavlic [Mon, 12 Jan 2009 16:11:32 -0500]:
>> That looks ugly to me. Any reason we shouldn't just "set +u" at the top of >> the script?
> As already discussed, because the script must be sourced, then the "set > +u" has global scope.
> I suppose that the option could be tested and then reset as appropriate > at the end of the script.
That does not help, because appart from being global, it of course takes effect at run time. In other words, it doesn't matter if set -u is active or not at function definition time, but at function invoation time.
> (note: for some reason Mercurial's bash completion script does not have > this problem; they use $1 directly without bash complaining)
Because (from a quick look) their completion script never expands a variable which is not known to be set.
-- Adeodato Simó dato at net.com.org.es Debian Developer adeodato at debian.org A hacker does for love what other would not do for money.