]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tools: bpftool: fix completion for "bpftool map update"
authorQuentin Monnet <quentin.monnet@netronome.com>
Sat, 20 Oct 2018 22:01:50 +0000 (23:01 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Sun, 21 Oct 2018 18:45:14 +0000 (20:45 +0200)
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>
tools/bpf/bpftool/bash-completion/bpftool

index c56545e87b0dddbd2340a0f4f3db9ecc1e94dd3b..3f78e6404589fc647bbecd555d49e9aa8fce3f15 100644 (file)
@@ -143,7 +143,7 @@ _bpftool_map_update_map_type()
     local type
     type=$(bpftool -jp map show $keyword $ref | \
         command sed -n 's/.*"type": "\(.*\)",$/\1/p')
-    printf $type
+    [[ -n $type ]] && printf $type
 }
 
 _bpftool_map_update_get_id()