[ovs-dev] [PATCH 07/21] completion.at: Improve portability

YAMAMOTO Takashi yamamoto at midokura.com
Mon Oct 19 04:28:58 UTC 2015


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 at midokura.com>
---
 tests/completion.at | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/completion.at b/tests/completion.at
index 0aca7aa..79093f9 100644
--- a/tests/completion.at
+++ b/tests/completion.at
@@ -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
-- 
2.3.8 (Apple Git-58)




More information about the dev mailing list