From mboxrd@z Thu Jan 1 00:00:00 1970 From: Quentin Monnet Subject: [PATCH bpf-next 3/3] tools: bpftool: fix completion for "bpftool map update" Date: Sat, 20 Oct 2018 23:01:50 +0100 Message-ID: <1540072910-29732-4-git-send-email-quentin.monnet@netronome.com> References: <1540072910-29732-1-git-send-email-quentin.monnet@netronome.com> Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Return-path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:34539 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbeJUGOM (ORCPT ); Sun, 21 Oct 2018 02:14:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id l6-v6so40534464wrt.1 for ; Sat, 20 Oct 2018 15:02:18 -0700 (PDT) In-Reply-To: <1540072910-29732-1-git-send-email-quentin.monnet@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 Reviewed-by: Jakub Kicinski --- tools/bpf/bpftool/bash-completion/bpftool | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool index c56545e87b0d..3f78e6404589 100644 --- a/tools/bpf/bpftool/bash-completion/bpftool +++ b/tools/bpf/bpftool/bash-completion/bpftool @@ -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() -- 2.7.4