Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp774122ybc; Sat, 16 Nov 2019 08:27:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwWMwuNyQnxd+t+Lje6qxHWeKn7oTQ95B3l3y01w0mYPe2fyTh0LBYhM4pvrKMLaZS9/k9R X-Received: by 2002:a17:906:234e:: with SMTP id m14mr10654098eja.94.1573921631409; Sat, 16 Nov 2019 08:27:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921631; cv=none; d=google.com; s=arc-20160816; b=CqkY9vr0+jXSLGl/UmnJlN40x0a2PlABpFQkchf08ujTE51oelRoSETZqR9rv7K5c6 SVtJv3JdPTrXIEO++1mwuyjSt2cainu6uukTucRt7EqpEHfSzeZlGVbJYJ4/qp8tMhRI aO8tKxvWK5b0t+q6wEe4Eq4oIM56gCdPOuvxNjHTEwp+8A2DUmSliOD4I4d3s8AxGssW VqWJUkX/6TbZalzV5TfpyCXC+wJPSfv44Pl9wGfyY8Od90eVWG3DHcKq36PEVocvYan6 cezPCifMUoccdWpx4dz3OcUb1+5drIEagCaIoH5de1MjpuSTMWnBCA7fSNYgoHq51nxy s/FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IXfyNEGFjeY3/LtfuzYSanFspurbHvK3aPnp+aotPVo=; b=OCWZMPQ1ob7SvXKIZiNO7To/jtztYghJmp7TjzYEQgdTa27ERFEJHyatdi1QhuVDe3 CFpGsbgugB345DL+1hFxgV+bxPGU5UEis7SWv4JPehaXhqVWSdEtsIOSop0xbbJLW1jS Gu6JM45sySqIyx2j8aaXT28VeWXXJeYNIxWN3E8cHCB466GdJBqtliib0Ufi3ZLlIzjw Dr3SDY8hmR3C5LIYSoZnSfP+kuBzo2NU17RGQRiRbbvMe2XBPEG/tYrU+ZhGkCnPA+Sq uTD4nKKVwPIjhyf5f5Z1WvfyJguwoAaTiuymZKIFM7J/B9Cxlx0sB5dl657mwQ0GYorB mjow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EYqYso9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si7955142ejv.152.2019.11.16.08.26.46; Sat, 16 Nov 2019 08:27:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EYqYso9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728676AbfKPPnS (ORCPT + 99 others); Sat, 16 Nov 2019 10:43:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728636AbfKPPnP (ORCPT ); Sat, 16 Nov 2019 10:43:15 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 155632072D; Sat, 16 Nov 2019 15:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918994; bh=Y18yuxI31zdXm3BrZcwrM5f7T94WmOvlXVgoXwJyH2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYqYso9iRWZrqG6STem5pJY/5XE9L7FTV7NofiepVXHgFNFcAnHndKCj5cpi+jtPQ j3jFE3VzlaYeqZJ0CLewmzP1/LTTXuIqDdACbnxICgVInXNklRA2BYC4w7Nx1BZwMX DvUVh03oHIb9UDA2C7u1r+hVyPbSh6dTHNB9alik= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Quentin Monnet , Jakub Kicinski , Daniel Borkmann , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 097/237] tools: bpftool: fix completion for "bpftool map update" Date: Sat, 16 Nov 2019 10:38:52 -0500 Message-Id: <20191116154113.7417-97-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quentin Monnet [ Upstream commit fe8ecccc10b3adc071de05ca7af728ca1a4ac9aa ] 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 Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- 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 598066c401912..c2b6b2176f3b7 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.20.1