bug-bash
[Top][All Lists]
Advanced

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

words in COMPWORDS vs. words in COMPREPLY


From: Ben Pfaff
Subject: words in COMPWORDS vs. words in COMPREPLY
Date: Tue, 20 Jul 2010 12:14:36 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

I'm trying to learn how bash completion works, so that I can
write completion functions for some utilities.

As an experiment, I wrote the following trivial completion.  It
is intended to report that the completions for the current word
are exactly the contents of the current word:

    _test () {
        COMPREPLY=(${COMP_WORDS[COMP_CWORD]})
    }
    complete -F _test test

I expected that, with the above, typing "test", followed by a
word, followed by <TAB>, would cause bash just to insert a space.
This is often what happens, but I've found some exceptions that I
do not yet understand.  For example, consider the following:
    test x=

When I press <TAB>, I expected this to expand to:
    test x=
followed by a space.

With Debian's bash 4.1-3 (on which bash --version reports
"version 4.1.5(1)-release"), this actually expands as:
    test x==
followed by a space.

With Debian's bash 3.2-4 ("bash 3.2.39(1)-release"), this expands
as:
    test x=x=
followed by a space.

Can anyone explain to me what bash is doing here?  I am trying to
write completion code for a utility that accepts some arguments
of the form "key1=value,key2=value,...", and this seemingly odd
behavior is making life difficult.

Thanks,

Ben.
-- 
Ben Pfaff 
http://benpfaff.org



reply via email to

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