Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash tab completion confused when one subcommand is a prefix of another #2316

Open
2 tasks done
dkg opened this issue Jan 28, 2021 · 0 comments
Open
2 tasks done

bash tab completion confused when one subcommand is a prefix of another #2316

dkg opened this issue Jan 28, 2021 · 0 comments
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-medium Call for participation: Experience needed to fix: Medium / intermediate 💸 $5

Comments

@dkg
Copy link

dkg commented Jan 28, 2021

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

  1. build and install sq from the sequoia-sq crate. sq has two subcommands with the unusual property that one is a prefix of another: key and keyring
  2. in bash, run touch keyfoo
  3. in bash, type sq k<TAB> and it fills in to sq key
  4. now hit <TAB> again.

Version

  • Rust: 1.48.0
  • Clap: 2.33.3

Actual Behavior Summary

sq key<TAB> completes to sq keyfoo because of the local file named keyfoo.

Expected Behavior Summary

It should require sq key<TAB><TAB> to show a list of two possible subcommands, key and keyring

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 type sq 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 to sq packetfoo .

This isn't likely to happen during normal usage because sq p<TAB> autocompletes to sq packet (note the trailing whitespace) and sq packet <TAB> (again, note the whitespace) actually does the right thing.

Debug output

sorry, i don't have debug output for this case.

@dkg dkg added the C-bug Category: Updating dependencies label Jan 28, 2021
@pksunkara pksunkara added this to the 3.1 milestone Mar 9, 2021
@pksunkara pksunkara added A-completion Area: completion generator 💸 $5 labels Mar 9, 2021
@epage epage removed this from the 3.1 milestone Dec 13, 2021
@epage epage added the E-medium Call for participation: Experience needed to fix: Medium / intermediate label Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-medium Call for participation: Experience needed to fix: Medium / intermediate 💸 $5
Projects
None yet
Development

No branches or pull requests

3 participants