completion.at: Improve portability
authorYAMAMOTO Takashi <yamamoto@midokura.com>
Wed, 14 Oct 2015 06:36:20 +0000 (06:36 +0000)
committerYAMAMOTO Takashi <yamamoto@midokura.com>
Thu, 26 Nov 2015 09:37:07 +0000 (18:37 +0900)
NetBSD's /bin/sh complains on the syntax of bash array.

While the use of eval might seem overkill, it's tricky to avoid
the error because the generated code will be a part of the surrounding
subshell and the syntax check is done a bit earlier than the execution
of these conditionals.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Acked-by: Ben Pfaff <blp@ovn.org>
tests/completion.at

index 0aca7aa..79093f9 100644 (file)
@@ -341,7 +341,8 @@ 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} || test ${BASH_VERSINFO[[0]]} -lt 4])
+AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
 OVS_VSWITCHD_START
 
 # complete ovs-vsctl --db=* [TAB]
@@ -422,7 +423,8 @@ AT_CLEANUP
 
 
 AT_SETUP([vsctl-bashcomp - argument completion])
-AT_SKIP_IF([test -z ${BASH_VERSION+x} || test ${BASH_VERSINFO[[0]]} -lt 4])
+AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
 OVS_VSWITCHD_START(
    [add-br br1 -- \
        set bridge br1 datapath-type=dummy -- \
@@ -748,7 +750,8 @@ AT_CLEANUP
 
 
 AT_SETUP([vsctl-bashcomp - negative test])
-AT_SKIP_IF([test -z ${BASH_VERSION+x} || test ${BASH_VERSINFO[[0]]} -lt 4])
+AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
 OVS_VSWITCHD_START
 
 # complete non-matching command.
@@ -786,4 +789,4 @@ OVS_VSWITCHD_STOP
 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test ""],
 [1], [])
 
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP