Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: bpftool: fix completion for "bpftool map update"

When trying to complete "bpftool map update" commands, the call to
printf would print an error message that would show on the command line
if no map is found to complete the command line.

Fix it by making sure we have map ids to complete the line with, before
we try to print something.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Quentin Monnet and committed by
Daniel Borkmann
fe8ecccc 06ee9da6

+1 -1
+1 -1
tools/bpf/bpftool/bash-completion/bpftool
··· 143 143 local type 144 144 type=$(bpftool -jp map show $keyword $ref | \ 145 145 command sed -n 's/.*"type": "\(.*\)",$/\1/p') 146 - printf $type 146 + [[ -n $type ]] && printf $type 147 147 } 148 148 149 149 _bpftool_map_update_get_id()