Skip to content

Bash command completion doesn't work #3440

Closed

Description

@wheleph

macOS version: 15.7.7 (24G720)
gopass version: 1.16.1-git+d601d3ef go1.26.3 darwin amd64
bash version: GNU bash, version 5.3.9(1)-release (x86_64-apple-darwin23.6.0)

I was so excited about the fix for #3435 that I decided to try out the new build right away. I've installed it in the following way:

  • go install github.com/gopasspw/gopass@2891435694d6428c5e91625bdd303db2b52e63ec
  • made sure that gopass binary is on $PATH:
~$ type -a gopass
gopass is /Users/wheleph/go/bin/gopass
  • tried to setup bash completion for gopass:
~$ gopass --version
gopass 1.16.1-git+d601d3ef go1.26.3 darwin amd64
~$ gopass completion bash > gopass-completion.bash
~$ cat gopass-completion.bash
_gopass_bash_autocomplete() {
     local cur opts base
     COMPREPLY=()
     cur="${COMP_WORDS[COMP_CWORD]}"
     # Use error handling to prevent crashes from invalid flags
     opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion 2>/dev/null ) || opts=""
     local IFS=$'\n'
     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
     return 0
 }

complete -F _gopass_bash_autocomplete gopass
~$ source gopass-completion.bash
~$ gopass sho<tab>
  • if I hit Tab key after typing gopass sho in Bash prompt then nothing happens, the expected subcommand show is not autocompleted

To debug the issue I removed stderr redirection in the following way and observed the error:

~$ cat gopass-completion.bash
_gopass_bash_autocomplete() {
     local cur opts base
     COMPREPLY=()
     cur="${COMP_WORDS[COMP_CWORD]}"
     # Use error handling to prevent crashes from invalid flags
     opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) || opts=""
     local IFS=$'\n'
     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
     return 0
 }

complete -F _gopass_bash_autocomplete gopass
~$ source gopass-completion.bash
~$ gopass sho
Error: Incorrect Usage: flag provided but not defined: -generate-bash-completion

2026/05/24 21:18:33 flag provided but not defined: -generate-bash-completion

Is it an issue in the gopass binary or did I install it incorrectly (which is totally possible since I'm a complete Golang noob).

Activity

  1. dominikschulz commented on May 24, 2026

    @dominikschulz
    Member

    Thanks for the report. This might be a setup issue. If your bash completion still points at the old binary is might be confsued.
    But it could very well be a bug as well. We just switched to a new major version of the CLI lib and that changes the way bash completion works a bit.

    I will try to reproduce and see if this is a bug that we need to fix.

  2. dominikschulz commented on May 24, 2026

    @dominikschulz
    Member

    Looks like a real bug. Thanks for reporting!

    We might need to little while to publish the next stable version, but I'll try to cut a new RC tomorrow.

  3. added a commit that references this issue on May 24, 2026
    0d41c38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址