On 06.08.2018 16:47, Timothy Redaelli wrote: > On Wed, 01 Aug 2018 17:00:11 +0300 > Ilya Maximets <[email protected]> wrote: > >> Aliases are not inheritable. To add a default options for utils >> executed in subshell we may try to catch them here and append >> options explicitly. >> >> There are still few cases with utils invocation in subshell inside >> the functions that we can not track this way, but they are not >> very frequent. >> >> Signed-off-by: Ilya Maximets <[email protected]> >> --- >> tests/ofproto-macros.at | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at >> index 2a56ae6..96219cd 100644 >> --- a/tests/ofproto-macros.at >> +++ b/tests/ofproto-macros.at >> @@ -107,7 +107,17 @@ sim_add () { >> # there. >> as() { >> if test "X$2" != X; then >> - (ovs_setenv $1; shift; "$@") >> + ( >> + ovs_setenv $1; shift; >> + cmd=$1; shift; >> + for util in $OVS_UTILS_LIST; do >> + if test "X$util" == "X$cmd"; then > ^^ > Tests are started with "/bin/sh" (that is not always bash), so please > use "=" instead of "==" since the latter is not portable and it doesn't > work on some shells (for example it doesn't work on dash that > Debian/Ubuntu uses by default).
Hmm. Thanks for pointing that. I know about sh and, actually, my main machine has ubuntu. It's kind of weird, but this code works perfectly on ubuntu with dash as a default shell. From the other side I see that '==' is a bash extension and it fails to work if I'm running it in dash by hands. That is strange. [root]$ ls -l /bin/sh lrwxrwxrwx 1 root root 4 Feb 17 2016 /bin/sh -> dash [root]$ /bin/sh $ test "abc" == "cde" /bin/sh: 1: test: abc: unexpected operator But, I rechecked twice and above code works while executing in a testsuite. --- Looking closely to the generated testsuite file I found that it, actually, tries to execute in as Bourne and/or POSIX as possible. It looks through all the available shells in a system and calls 'exec' to continue execution inside it. Look for "AS_BOURNE_COMPATIBLE" for details. So, reality is that most of linux distros has bash installed and it will be chosen regardless of configured default shell. --- Anyway, I'll change '==' to '=' because it looks sane. This will help for systems that doesn't have bash installed, or for the cases where shell is hard-chosen by user. Best regards, Ilya Maximets. > >> + $cmd --timeout=$OVS_TIMEOUT "$@" >> + exit "$?" >> + fi >> + done >> + $cmd "$@" >> + ) >> else >> ovs_setenv $1 >> fi > > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
