> diff --git a/tools/bpf/bpftool/bash-completion/bpftool 
> b/tools/bpf/bpftool/bash-completion/bpftool
> index 75cbcb512ebae..c9e8761e4ef2a 100644
> --- a/tools/bpf/bpftool/bash-completion/bpftool
> +++ b/tools/bpf/bpftool/bash-completion/bpftool

[ ... ]

> @@ -50,12 +50,19 @@ _bpftool_get_map_ids()
>          command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) )
>  }
>
> -# Takes map type and adds matching map ids to the list of suggestions.
> -_bpftool_get_map_ids_for_type()
> +# Takes map types and prints a pattern matching their JSON type fields.
> +_bpftool_build_type_pattern()
>  {
> -    local type="$1"
> +    local IFS='|'
> +    printf '"type": "(%s)"\n' "$*"
> +}
> +
> +# Takes map types and adds matching map ids to the list of suggestions.
> +_bpftool_get_map_ids_for_types()
> +{
> +    local types=$(_bpftool_build_type_pattern "$@")
>      COMPREPLY+=( $( compgen -W "$( bpftool -jp map  2>&1 | \
> -        command grep -C2 "$type" | \
> +        command grep -C2 -E "$types" | \
>          command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) )
>  }

This isn't a bug, but the switch from a bare substring grep to an
anchored '"type": "..."' match also tightens the existing
stack/queue/struct_ops completions. For example, 'bpftool map peek id'
previously matched "type": "stack_trace" because it contained the
substring 'stack', so stack_trace map IDs were suggested; they no longer
are. Maps whose name contained 'stack' or 'queue' were likewise picked
up via the -C2 window and no longer are.

The tightening is well motivated for the new ringbuf call (it keeps
user_ringbuf out of the event_pipe suggestions), and every type string
used is an exact libbpf map_type_name[] entry, so nothing is wrongly
excluded. Would it be worth a line in the changelog about this behavior
change to unrelated completions, or splitting the anchoring out from the
ringbuf support?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35575071830

Reply via email to