diff mbox series

[1/1] net/sctp: Fix parsing input variables in dash

Message ID 20180515094053.18355-1-pvorel@suse.cz
State Accepted
Delegated to: Petr Vorel
Headers show
Series [1/1] net/sctp: Fix parsing input variables in dash | expand

Commit Message

Petr Vorel May 15, 2018, 9:40 a.m. UTC
Dash (and maybe some other posix shells) cannot handle unquoted $@.
It needs to be quoted when calling otherwise leads to error:
/opt/ltp/testcases/bin/sctp01.sh: 40: local: 65000: bad variable name

This is a quick fix, better than working with input parameters would be
add another test case in runtest/net.features.

Fixes: 7ade6a32e ("sctp: add test-case with random payload")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/sctp/sctp01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis May 15, 2018, 12:04 p.m. UTC | #1
Hi!
> Dash (and maybe some other posix shells) cannot handle unquoted $@.
> It needs to be quoted when calling otherwise leads to error:
> /opt/ltp/testcases/bin/sctp01.sh: 40: local: 65000: bad variable name

It looks like this patch is working around the real problem.

Looking into bash and dash manual pages the syntax for local builtin is
slightly differente between these two.

The dash contains:

local [variable | -] ...

While bash has:

local [option] [name[=value] ... | - ]


So it looks to me like the portable way how to declare local variables is:

function()
{
	local var_name

	var_name=$foo

	...
}


And it also seems to be mentioned in one of the dash porting guides:

http://mywiki.wooledge.org/Bashism

See the builtins paragraph there.
Petr Vorel May 15, 2018, 1:11 p.m. UTC | #2
Hi Cyril,

> Hi!
> > Dash (and maybe some other posix shells) cannot handle unquoted $@.
> > It needs to be quoted when calling otherwise leads to error:
> > /opt/ltp/testcases/bin/sctp01.sh: 40: local: 65000: bad variable name

> It looks like this patch is working around the real problem.

> Looking into bash and dash manual pages the syntax for local builtin is
> slightly differente between these two.

> The dash contains:

> local [variable | -] ...

> While bash has:

> local [option] [name[=value] ... | - ]


> So it looks to me like the portable way how to declare local variables is:

> function()
> {
> 	local var_name

> 	var_name=$foo

> 	...
> }


> And it also seems to be mentioned in one of the dash porting guides:

> http://mywiki.wooledge.org/Bashism

> See the builtins paragraph there.

Thanks for explanation!
Pushed your way, with your Acked-by and Suggested-by.


Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/network/sctp/sctp01.sh b/testcases/network/sctp/sctp01.sh
index bf13521c2..c4149af19 100755
--- a/testcases/network/sctp/sctp01.sh
+++ b/testcases/network/sctp/sctp01.sh
@@ -58,6 +58,6 @@  test_run()
 
 setup
 test_run
-test_run -A 65000
+test_run '-A 65000'
 
 tst_exit