From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E1DFC4320A for ; Fri, 30 Jul 2021 21:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 671616024A for ; Fri, 30 Jul 2021 21:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbhG3V4J (ORCPT ); Fri, 30 Jul 2021 17:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbhG3VzR (ORCPT ); Fri, 30 Jul 2021 17:55:17 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1202C0613D3; Fri, 30 Jul 2021 14:55:10 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id s48so18259799ybi.7; Fri, 30 Jul 2021 14:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ucMlZDLq0PkPJN6sHPh2Ls6egiVhlPqu3vmw+xBT+sY=; b=PLTHNBvXfstcgRMLKjG3pl3KbIZdwoIe1C4QfICkQZ3rTEBIC3WVtVql0nOFNKrf6M Ozo1IPfbM49xloWLJv0UppRC5re3tHeBEm0O3WmtErCGx6KsInzGsMnM58R3q/eCixfb w8TXWoj1NHPz09Qm3QsF2twHfkjxJIdz7FpOAgTFCH/iA4CYcZfM6Vf+Wg0QFfTTslaj n7aPT7xAQ09saI+za6QRjt1vnmnZJyzYszX+3+n3W6XYF0qBNOhp4NH1SZYSl3y/kIz0 jxOL0piugFeOLDIBrJGzqfoM2B5nWBj+/Grs2E8FbdUXHtZh7TvbfbIyEJDWnK8lAhlq V72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ucMlZDLq0PkPJN6sHPh2Ls6egiVhlPqu3vmw+xBT+sY=; b=QWfAzCqcCZRBtQOR34EfgVLlLB+rKBPxG9/017PghSTxKgQNkh7O/xAWhS/3oxZHrr U2RvtgAjDhBIUvNsp9fo/q+qFDiTv4WzRWwajkj26WKNYxQhpysLDpvEfZyBubML6osg nPQRy/OeX410a2zeB0JZEtw/45DPUgIGMScjdV2Kvm6UsLRuPrgg8Gx3vrGIvDxW6ZAm YBhngyAW6UJndX1SNUwXX12hZ+5v9xEUfpRdkfFCPs6Fu9dGdYXSqmDxNCFfdHRu8oJR qeDHvrYeTT+ikj+kkm2WIMesBLHb4I/2zxhWIlQ3XB6eo3OHRWd8Ckv9WSsxVJ/P5BQM 3lnw== X-Gm-Message-State: AOAM530t2lSQ2MmjmhDsGsH3hmK0Qt8Mt/vT9E2DD394h4Yz4lWI1h+I y/ZHROz5B4QQSqx6SSB50Qc6dS+KQL5IPZwzTWA= X-Google-Smtp-Source: ABdhPJzgvD1MFK7zmqHhFL+sX2/ltjsgVlVBVvt6Iv4tz8VnJHZ0k1gWfpdn0Sw8u7dw/ooHA+OOyJKdOsNlE2Ie2IM= X-Received: by 2002:a25:9942:: with SMTP id n2mr6130377ybo.230.1627682109757; Fri, 30 Jul 2021 14:55:09 -0700 (PDT) MIME-Version: 1.0 References: <20210729162932.30365-1-quentin@isovalent.com> <20210729162932.30365-2-quentin@isovalent.com> In-Reply-To: From: Andrii Nakryiko Date: Fri, 30 Jul 2021 14:54:58 -0700 Message-ID: Subject: Re: [PATCH bpf-next 1/7] tools: bpftool: slightly ease bash completion updates To: Quentin Monnet Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Fri, Jul 30, 2021 at 2:47 PM Quentin Monnet wrote: > > 2021-07-30 11:45 UTC-0700 ~ Andrii Nakryiko > > On Thu, Jul 29, 2021 at 9:29 AM Quentin Monnet wrote: > >> > >> Bash completion for bpftool gets two minor improvements in this patch. > >> > >> Move the detection of attach types for "bpftool cgroup attach" outside > >> of the "case/esac" bloc, where we cannot reuse our variable holding the > >> list of supported attach types as a pattern list. After the change, we > >> have only one list of cgroup attach types to update when new types are > >> added, instead of the former two lists. > >> > >> Also rename the variables holding lists of names for program types, map > >> types, and attach types, to make them more unique. This can make it > >> slightly easier to point people to the relevant variables to update, but > >> the main objective here is to help run a script to check that bash > >> completion is up-to-date with bpftool's source code. > >> > >> Signed-off-by: Quentin Monnet > >> --- > >> tools/bpf/bpftool/bash-completion/bpftool | 57 +++++++++++++---------- > >> 1 file changed, 32 insertions(+), 25 deletions(-) > >> > >> diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool > >> index cc33c5824a2f..b2e33a2d8524 100644 > >> --- a/tools/bpf/bpftool/bash-completion/bpftool > >> +++ b/tools/bpf/bpftool/bash-completion/bpftool > >> @@ -404,8 +404,10 @@ _bpftool() > >> return 0 > >> ;; > >> 5) > >> - COMPREPLY=( $( compgen -W 'msg_verdict stream_verdict \ > >> - stream_parser flow_dissector' -- "$cur" ) ) > >> + local BPFTOOL_PROG_ATTACH_TYPES='msg_verdict \ > >> + stream_verdict stream_parser flow_dissector' > >> + COMPREPLY=( $( compgen -W \ > >> + "$BPFTOOL_PROG_ATTACH_TYPES" -- "$cur" ) ) > >> return 0 > >> ;; > >> 6) > >> @@ -464,7 +466,7 @@ _bpftool() > >> > >> case $prev in > >> type) > >> - COMPREPLY=( $( compgen -W "socket kprobe \ > >> + local BPFTOOL_PROG_LOAD_TYPES='socket kprobe \ > >> kretprobe classifier flow_dissector \ > >> action tracepoint raw_tracepoint \ > >> xdp perf_event cgroup/skb cgroup/sock \ > >> @@ -479,8 +481,9 @@ _bpftool() > >> cgroup/post_bind4 cgroup/post_bind6 \ > >> cgroup/sysctl cgroup/getsockopt \ > >> cgroup/setsockopt cgroup/sock_release struct_ops \ > >> - fentry fexit freplace sk_lookup" -- \ > >> - "$cur" ) ) > >> + fentry fexit freplace sk_lookup' > >> + COMPREPLY=( $( compgen -W \ > >> + "$BPFTOOL_PROG_LOAD_TYPES" -- "$cur" ) ) > > > > nit: this and similar COMPREPLY assignments now can be on a single line now, no? > > It will go over 80 characters, but OK, it will probably be more readable > on a single line. I'll change for v2. 80 character rule was lifted a while ago. 100 is totally fine. And in some special cases readability beats even 100, IMO.