bpftool: Address minor issues in bash completion
authorQuentin Monnet <qmo@kernel.org>
Sat, 13 Apr 2024 01:14:27 +0000 (02:14 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Apr 2024 15:58:25 +0000 (17:58 +0200)
commitad2d22b617b7c0ca2cff4da6dc063183822484bb
tree84c66b43645315de17e0cde4ef7ac3bf93ad92e6
parent986e7663f98ec7441d9d948263ec0dda71e7479f
bpftool: Address minor issues in bash completion

This commit contains a series of clean-ups and fixes for bpftool's bash
completion file:

- Make sure all local variables are declared as such.
- Make sure variables are initialised before being read.
- Update ELF section ("maps" -> ".maps") for looking up map names in
  object files.
- Fix call to _init_completion.
- Move definition for MAP_TYPE and PROG_TYPE higher up in the scope to
  avoid defining them multiple times, reuse MAP_TYPE where relevant.
- Simplify completion for "duration" keyword in "bpftool prog profile".
- Fix completion for "bpftool struct_ops register" and "bpftool link
  (pin|detach)" where we would repeatedly suggest file names instead of
  suggesting just one name.
- Fix completion for "bpftool iter pin ... map MAP" to account for the
  "map" keyword.
- Add missing "detach" suggestion for "bpftool link".

Signed-off-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20240413011427.14402-3-qmo@kernel.org
tools/bpf/bpftool/bash-completion/bpftool