Skip to content

Bash autocomplete broken for nix-store --gc --print-roots #16069

Description

@Momi-V

Describe the bug

nix-store --gc -- outputs:

$  nix-store --gc --
--delete)--print-roots  --include               --option                --print-dead            --version
--help                  --max-freed             --print*                --print-live            

instead of --print-roots autocomplete is suggesting --delete)--print-roots which is not a valid command.
--delete should not be suggested as an option for --gc at all

Steps To Reproduce

  1. Open terminal with bash shell
  2. type nix-store --gc --
  3. Hit tab

Expected behavior

$  nix-store --gc --
--help           --max-freed       --print*             --print-live         --version
--include      --option             --print-dead     --print-roots    

Metadata

nix-env (Nix) 2.34.7

Additional context

  1. find /nix/ -iname nix-store to find share/bash-completion/completions/nix-store
  2. cat /nix/store/y0kdq8sxjy9jmdr9pv2gq78vpmzvxpf8-system-path/share/bash-completion/completions/nix-store > completions
  3. Line 417-422:
    local -a nix_gc_common=(
        '(- --print* --delete)--print-roots'
            '(-|--print*|--delete)--print-live'
            '(-|--print*|--delete)--print-dead'
            '(-|--print*|--delete)--delete'
            )

print-roots is missing 2 | symbols

I believe src/nix/nix-store/nix-store.cc and misc/bash/completion.sh are doing some unholy shell magic to generate this, but I'm not sure where the | is getting lost

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions