Commit 8fc9f8be authored by Quentin Monnet's avatar Quentin Monnet Committed by Daniel Borkmann

tools: bpftool: add completion for bpftool prog "loadall"

Bash completion for proposing the "loadall" subcommand is missing. Let's
add it to the completion script.

Add a specific case to propose "load" and "loadall" for completing:

    $ bpftool prog load
                       ^ cursor is here

Otherwise, completion considers that $command is in load|loadall and
starts making related completions (file or directory names, as the
number of words on the command line is below 6), when the only suggested
keywords should be "load" and "loadall" until one has been picked and a
space entered after that to move to the next word.
Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent bef8e263
......@@ -342,6 +342,13 @@ _bpftool()
load|loadall)
local obj
# Propose "load/loadall" to complete "bpftool prog load",
# or bash tries to complete "load" as a filename below.
if [[ ${#words[@]} -eq 3 ]]; then
COMPREPLY=( $( compgen -W "load loadall" -- "$cur" ) )
return 0
fi
if [[ ${#words[@]} -lt 6 ]]; then
_filedir
return 0
......@@ -435,7 +442,7 @@ _bpftool()
*)
[[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'dump help pin attach detach \
load show list tracelog run' -- "$cur" ) )
load loadall show list tracelog run' -- "$cur" ) )
;;
esac
;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment