public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Danielle Ratson <danieller@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <jiri@resnulli.us>, <dsahern@kernel.org>,
	Danielle Ratson <danieller@nvidia.com>
Subject: [PATCH iproute2-next] bash-completion: devlink: Fix dev completion trailing colon
Date: Sun, 26 Apr 2026 14:51:39 +0300	[thread overview]
Message-ID: <20260426115139.712959-1-danieller@nvidia.com> (raw)

Cited commit extended 'devlink dev show' to print the instance index when
the kernel provides DEVLINK_ATTR_INDEX, printing the device handle followed
by a colon and the index. The completion code was using the raw text output
as a word list, causing the device handle to be offered with a trailing
colon, e.g. "pci/0000:01:00.0:" instead of "pci/0000:01:00.0".

Switch to JSON output and extract device names using jq, consistent
with how port completion already works, to reliably get only the device
handle names regardless of what additional attributes are printed.

Fixes: 36252727bfc6 ("devlink: show devlink instance index in dev output")
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 bash-completion/devlink | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bash-completion/devlink b/bash-completion/devlink
index c053d3d0..7ec6a7cb 100644
--- a/bash-completion/devlink
+++ b/bash-completion/devlink
@@ -31,7 +31,8 @@ _devlink_direct_complete()
 
     case $1 in
         dev)
-            value=$(devlink dev show 2>/dev/null)
+            value=$(devlink -j dev show 2>/dev/null \
+                    | jq -r '.dev | keys[]')
             ;;
         selftests_id)
             dev=${words[4]}
-- 
2.51.0


                 reply	other threads:[~2026-04-26 11:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260426115139.712959-1-danieller@nvidia.com \
    --to=danieller@nvidia.com \
    --cc=dsahern@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox