bash tab completion confused when one subcommand is a prefix of another #2316
Labels
A-completion
Area: completion generator
C-bug
Category: Updating dependencies
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
💸 $5
Make sure you completed the following tasks
Code
Please see sequoia's sq for code. The problem i'm reporting is that
sq key<TAB>
does the wrong thing.I reported this concern to sequoia and they indicated that it is a bug in clap's bash tab completion. I describe it in more detail below.
Steps to reproduce the issue
sq
from thesequoia-sq
crate.sq
has two subcommands with the unusual property that one is a prefix of another:key
andkeyring
touch keyfoo
sq k<TAB>
and it fills in tosq key
<TAB>
again.Version
Actual Behavior Summary
sq key<TAB>
completes tosq keyfoo
because of the local file namedkeyfoo
.Expected Behavior Summary
It should require
sq key<TAB><TAB>
to show a list of two possible subcommands,key
andkeyring
Additional context
I note that the problem might be deeper than just when one subcommand is a prefix of another, though the prefix situation makes it more evident.
For example,
sq
has another subcommand with no lexical overlap with other subcommands:packet
.If i
touch packetfoo
and then in bash typesq packet<TAB>
(note the lack of trailing whitespace), I'd expect bash to insert a space (because the subcommand token is complete, so we should move on to generating the next token). Instead, it autocompletes tosq packetfoo
.This isn't likely to happen during normal usage because
sq p<TAB>
autocompletes tosq packet
(note the trailing whitespace) andsq packet <TAB>
(again, note the whitespace) actually does the right thing.Debug output
sorry, i don't have debug output for this case.
The text was updated successfully, but these errors were encountered: