The ovs-vsctl-bashcomp script does not work properly on bash (version
 < 4.0).  This commit adds test for the bash version and avoids running
the script/test when the bash version is not supported.

Signed-off-by: Alex Wang <[email protected]>
---
 tests/completion.at               |    6 +++---
 utilities/ovs-vsctl-bashcomp.bash |    5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/completion.at b/tests/completion.at
index 2de4a2c..d3b2800 100644
--- a/tests/completion.at
+++ b/tests/completion.at
@@ -341,7 +341,7 @@ echo "$@" | tr ' ' '\n' | sed -e '/^$/d' | sed -e 's/$/ /g' 
| sort -u
 ])
 
 AT_SETUP([vsctl-bashcomp - basic verification])
-AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([test -z ${BASH_VERSION+x} || test ${BASH_VERSINFO[[0]]} -lt 4])
 OVS_VSWITCHD_START
 
 # complete ovs-vsctl --db=* [TAB]
@@ -422,7 +422,7 @@ AT_CLEANUP
 
 
 AT_SETUP([vsctl-bashcomp - argument completion])
-AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([test -z ${BASH_VERSION+x} || test ${BASH_VERSINFO[[0]]} -lt 4])
 OVS_VSWITCHD_START(
    [add-br br1 -- \
        set bridge br1 datapath-type=dummy -- \
@@ -748,7 +748,7 @@ AT_CLEANUP
 
 
 AT_SETUP([vsctl-bashcomp - negative test])
-AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([test -z ${BASH_VERSION+x} || test ${BASH_VERSINFO[[0]]} -lt 4])
 OVS_VSWITCHD_START
 
 # complete non-matching command.
diff --git a/utilities/ovs-vsctl-bashcomp.bash 
b/utilities/ovs-vsctl-bashcomp.bash
index 8f73ce1..e79c6a2 100755
--- a/utilities/ovs-vsctl-bashcomp.bash
+++ b/utilities/ovs-vsctl-bashcomp.bash
@@ -630,6 +630,11 @@ _ovs_vsctl_bashcomp () {
     local cur valid_globals cmd_args raw_cmd cmd_pos valid_globals valid_opts
     local test="false"
 
+    # Does not support BASH_VERSION < 4.0
+    if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
+        return 0
+    fi
+
     # Prepare the COMP_* variables based on input.
     if [ "$1" = "test" ]; then
         test="true"
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to