Skip to contentSkip to conversation

bash-completion: devlink: Fix dev completion trailing colon

PATCH Applied Danielle Ratson 2 participants 2 messages Apr 26 – Apr 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash-completion: devlink: Fix dev completion trailing colon

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")
---
 bash-completion/devlink | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bash-completion/devlink +2 -1
index c053d3d0..7ec6a7cb 100644
@@ -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]}
Signature · 1 line
2.51.0
#1 lore raw
This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 11 lines · On Sun, 26 Apr 2026 14:51:39 +0300 you wrote:

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.

[...]

Here is the summary with links:
- [iproute2-next] bash-completion: devlink: Fix dev completion trailing colon

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=03b33c7550e9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html