瀏覽代碼

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>
Quentin Monnet 6 年之前
父節點
當前提交
fe8ecccc10
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      tools/bpf/bpftool/bash-completion/bpftool

+ 1 - 1
tools/bpf/bpftool/bash-completion/bpftool

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