bug-bash
[Top][All Lists]
Advanced

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

set -u can cause trouble with pcompletion functions


From: Tobias C. Rittweiler
Subject: set -u can cause trouble with pcompletion functions
Date: Sun, 2 Feb 2003 22:22:58 +0100

Hello List,

as I'm not subscribed to the list, please CC me.

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  -g -O2
uname output: Linux brood 2.5.59 #1 Thu Jan 23 19:58:32 CET 2003 i586 unknown 
unknown GNU/Linux
Machine Type: i586-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
        The `nounset' (u) option can cause some trouble with the
        programmable completion, more precisely with self-defined
        functions.

        For instance some functions of the official
        /etc/bash_completion file don't work properly if `nounset' is
        set. _cd() is only one example, here is the relevant code
        snippet:

        2413 # we have a CDPATH, so loop on its contents
        2414 for i in ${CDPATH//:/$'\t'}; do
        2415         # create an array of matched subdirs
        2416         k=${#COMPREPLY[@]}
        2417         for j in $( compgen -d $i/$cur ); do
        2418                 COMPREPLY[$k]=${j#$i/}
        2419                 k=$((++k))
        2420         done
        2421 done

        `COMPREPLY' isn't set previously and that's why bash complains
        about an unbound variable.

        Yes, this may be called a feature rather than a bug, but
        nevertheless it's quite annoying one way or the other.
        
Repeat-By:
        $ func() { echo $CAUSE_AN_ERROR; }
        $ complete -F func blah
        $ blah [tab]
        
Fix:
        Well, you might say now: Fix that buggy bash_completion!
        That's certainly right, but since I can't imagine any reason why
        `nounset' should be evaluated in a function called by
        pcompletion (unless -u has been expliticely set within that
        function), I attached a small patch that disables
        `unbound_vars_is_error' in
        pcomplete.c::gen_shell_function_matches() and
        ::gen_command_matches().

        
-- 
cheers,
 Tobias                                       <tobrit@freebits.de>

http://freebits.org   - "Unix? What's that? Is that like Linux?  "
http://rocklinux.org  - "I'm a hacker, and I'm using ROCK Linux. "

"In heaven all the interesting people are missing."
 -- Friedrich Nietzsche

"Freedom is just Chaos, with better lighting."
 -- Alan Dean Foster

Attachment: bash-2.05b-unbound_vars-and-pcompletion.diff
Description: Binary data


reply via email to

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