From ec8fe88d73dea48cc87de616c478d752c8e7535d Mon Sep 17 00:00:00 2001 From: Markus Linnala Date: Sun, 19 Jan 2025 16:37:15 +0200 Subject: [PATCH] utilities/bashcomp: Do not run ovs-vsctl when not possible. Bash command completion setup is done during login process. If a command is not available, but it is tried to be run, there is then inconvenient error messages at each login. Signed-off-by: Markus Linnala Signed-off-by: Simon Horman --- utilities/ovs-vsctl-bashcomp.bash | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utilities/ovs-vsctl-bashcomp.bash b/utilities/ovs-vsctl-bashcomp.bash index c5ad24fb7..5313fa9d4 100644 --- a/utilities/ovs-vsctl-bashcomp.bash +++ b/utilities/ovs-vsctl-bashcomp.bash @@ -32,11 +32,15 @@ _ovs_vsctl () { # A bar (|) character in an argument means thing before bar OR thing # after bar; for example, del-port can take a port or an interface. -_OVS_VSCTL_COMMANDS="$(_ovs_vsctl --commands)" +_OVS_VSCTL_COMMANDS= +_OVS_VSCTL_OPTIONS= +if command -v ovs-vsctl > /dev/null; then + _OVS_VSCTL_COMMANDS="$(_ovs_vsctl --commands)" -# This doesn't complete on short arguments, so it filters them out. -_OVS_VSCTL_OPTIONS="$(_ovs_vsctl --options | awk '/^--/ { print $0 }' \ - | sed -e 's/\(.*\)=ARG/\1=/')" + # This doesn't complete on short arguments, so it filters them out. + _OVS_VSCTL_OPTIONS="$(_ovs_vsctl --options | awk '/^--/ { print $0 }' \ + | sed -e 's/\(.*\)=ARG/\1=/')" +fi IFS=$SAVE_IFS declare -A _OVS_VSCTL_PARSED_ARGS