Skip to content

Bash completion errors for invalid subcommands #975

Closed

Description

@oturpe

Describe the bug
I was trying to remove a container I do not need any more.
The name of the container was rawhide-test,
so I typed: $ toolbox remove raw
and tried to save me some typing by invoking bash completion with <Tab>.
The following error was printed:

bash: options: bad array subscript

This happens because remove is not a Toolbox subcommand,
the correct command is rm,
In which case bash completion works as expected.
But, every other tool's bash completion simply does not complete or suggest anything
when there are no completions available.

Steps how to reproduce the behaviour
1.Type, but do not hit enter: $ toolbox invalid-command
2. Invoke bash completion by hitting <Tab>

Expected behaviour
Nothing happens.

Actual behaviour
Error as given in the description appears.

Screenshots
n/a

Output of toolbox --version (v0.0.90+)
toolbox version 0.0.99.2

Toolbox package info (rpm -q toolbox)
toolbox-0.0.99.2^3.git075b9a8d2779-4.fc35.x86_64

Output of podman version

Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.16.8
Built:        Wed Dec  8 23:45:07 2021
OS/Arch:      linux/amd64

Podman package info (rpm -q podman)
podman-3.4.4-1.fc35.x86_64

Info about your OS
Fedora Workstation 35

Additional context
n/a

Activity

  1. added
    1. Bug
    on Jan 8, 2022
  2. martymichal commented on Jan 8, 2022

    @martymichal
    Member

    Thank you for the report, @oturpe! I can reproduce it on my machine, too. I believe #840 should fix this.

  3. linked a pull request that will close this issuecmd: Added shell completion command #840on Jan 8, 2022
  4. added this to the Release 0.1.0 milestone on Jan 8, 2022
  5. olivergs commented on Jan 10, 2022

    @olivergs
    Collaborator

    The problem right now is that the completion file shipped is out of sync with the completion system we already have implemented upstream.

    If you want a workaround, just do:

    toolbox completion bash > right_completions

    and then

    source ./right_completions

    After that you will get the right behaviour.

    The fix upstream should be as easy as replacing the current bash completion file with the contents of the right_completions file.

  6. oturpe commented on Jan 10, 2022

    @oturpe
    ContributorAuthor

    Thank you both!
    Pull request #840 does fix the problem,
    as does using the completions from $ toolbox completion bash.
    However, both solutions could still be improved like I explain in this pr comment

    I am also wondering, if there is a generator for completions in place,
    why is it not run during build and the result installed?
    Then the completions would never get out of sync.

  7. martymichal commented on Jan 10, 2022

    @martymichal
    Member

    Pull request #840 does fix the problem, as does using the completions from $ toolbox completion bash.

    Mmm... I believe these are the same :).

    However, both solutions could still be improved like I explain in this pr comment

    Thanks for the insight!

    I am also wondering, if there is a generator for completions in place, why is it not run during build and the result installed? Then the completions would never get out of sync.

    That's what #840 is trying to accomplish :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. Bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions