Skip to content

Bash completion script is broken if an argument() metavar contains spaces #563

@joffrey-bion

Description

@joffrey-bion

I have a command like this, and for some reason someone decided to put spaces in the arguments metavar:

internal class RunCommand : AmperSubcommand(name = "run") {
    private val programArguments by argument(name = "program arguments").multiple()

   // ...
}

When sourcing the generated bash completion for this, I get the following error:

-bash: /home/jbion/amper-completion.bash: line 539: syntax error near unexpected token `arguments'
-bash: /home/jbion/amper-completion.bash: line 539: `    program arguments)'

Adding quotes around program arguments in the completion script solves the problem.

I guess there are 2 ways this could be solved:

  1. forbid spaces (and other chars that could mess up with bash) in the metavar name with an explicit doc and error
  2. quote the metavar name in the bash case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions