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

Short option autocompleted with an extra equal sign (Bash) #14

Open
born4new opened this issue Jun 6, 2016 · 0 comments
Open

Short option autocompleted with an extra equal sign (Bash) #14

born4new opened this issue Jun 6, 2016 · 0 comments

Comments

@born4new
Copy link

born4new commented Jun 6, 2016

Here is my test program:

Usage:
  #{__FILE__} [--test=<test-value>]
  #{__FILE__} -h | --help | --version

Options:
  -h, --help               Shows this screen.
  -v, --version            Display the program version.
  -t, --test <test-value>  My own test value

Here are some use-cases for the above program (I'm using docopt.rb here):

# Valid case: long option with equals sign
./docopt-test.rb --test=1234

# Output
{"--test"=>"1234", "--help"=>false, "--version"=>false}

# Valid case: short option with a space
./docopt-test.rb -t 1234

# Output
{"--test"=>"1234", "--help"=>false, "--version"=>false}

# Invalid case: short option with an equal sign
./docopt-test.rb -t=1234

# Output (the value is =1234 here)
{"--test"=>"=1234", "--help"=>false, "--version"=>false}

Here is the autocomplete file I get when using this tool:

_docopttestrb()
{
    local cur
    cur="${COMP_WORDS[COMP_CWORD]}"

    if [ $COMP_CWORD -ge 1 ]; then
        COMPREPLY=( $( compgen -W '-t= --test= -h --help -h --help -v --version ' -- $cur) )
    fi
}

complete -o bashdefault -o default -o filenames -F _docopttestrb docopt-test.rb

It basically only autocompletes with -t=, which is an invalid option as far as docopt is concerned.

Is this a problem on my script or could this be a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant