From 78f179b53eaf5a1c2865ee748656ac302201e710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Tue, 11 Mar 2025 12:54:13 +0100 Subject: [PATCH] nmcli: fix argument completion if nmcli is aliased If an alias like `nmcli=nmcli --some-arguments` is used, bash completion doesn't work. Fix it by using `command nmcli` from the nmcli-completion script, so we ensure that the --complete-args is passed directly to nmcli binary, not through an alias. Contributed-by: Jonas Belouadi (@potamides) Fixes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1734 --- src/nmcli/nmcli-completion | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nmcli/nmcli-completion b/src/nmcli/nmcli-completion index f2de7b675..0c9b51560 100644 --- a/src/nmcli/nmcli-completion +++ b/src/nmcli/nmcli-completion @@ -49,7 +49,10 @@ _nmcli() cur='' fi - output="$(nmcli --complete-args "${words[@]}" 2>/dev/null)" + # If the user set an alias like `nmcli=nmcli --some-arguments`, then --complete-args + # might give unexpected behaviours. Use `command` to ensure that aliases are ignored + # and the nmcli binary is used directly. + output="$(command nmcli --complete-args "${words[@]}" 2>/dev/null)" # Bail out early if we're completing a file name if [ $? = 65 ]; then