[ovs-dev,07/21] completion.at: Improve portability
diff mbox

Message ID 1445228952-22445-7-git-send-email-yamamoto@midokura.com
State Awaiting Upstream
Headers show

Commit Message

Takashi Yamamoto Oct. 19, 2015, 4:28 a.m. UTC
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>
---
 tests/completion.at | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Ben Pfaff Nov. 9, 2015, 11:27 p.m. UTC | #1
On Mon, Oct 19, 2015 at 01:28:58PM +0900, YAMAMOTO Takashi wrote:
> 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>

Patch
diff mbox

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