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

Shell completion fails for commands with dash in their name #104

Closed
stellingsimon opened this issue Dec 14, 2019 · 0 comments · Fixed by #105
Closed

Shell completion fails for commands with dash in their name #104

stellingsimon opened this issue Dec 14, 2019 · 0 comments · Fixed by #105

Comments

@stellingsimon
Copy link
Contributor

Thank you for this beautiful library. I'm enjoying it very much!

I found the following bug related to Bash completion:

When a command contains a dash in its name, e.g.

class Entity : CliktCommand(name = "crud-entity")

its arguments/options cannot be completed successfully, instead an error message appears on the prompt:

$ mytool crud-entity <TAB>
_mytool_crud-entity: command not found

The reason is the following: the generated Bash script contains an error:

    case "${COMP_WORDS[$i]}" in
      crud-entity)
        _mytool_crud-entity $(( i + 1 )) # note the dash. Bash does not allow dashes as part of a function name, so this cannot work!
        return
        ;;

# ...

_mytool_crud_entity() { # note the underscore. The function is defined correctly.
  local i=$1
  local in_param=''
# ...
@stellingsimon stellingsimon changed the title Bash completion cannot handle commands with dash in their name Shell completion fails for commands with dash in their name Dec 14, 2019
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

Successfully merging a pull request may close this issue.

1 participant