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 <[email protected]>
---
 utilities/ovs-vsctl-bashcomp.bash | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 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)"
-
-# 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=/')"
+_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=/')"
+fi
 IFS=$SAVE_IFS
 
 declare -A _OVS_VSCTL_PARSED_ARGS
-- 
2.48.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to