Skip to contentSkip to conversation

net/sctp: Fix parsing input variables in dash

PATCH New Petr Vorel 2 participants 3 messages May 15, 2018

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 net/sctp: Fix parsing input variables in dash

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")
---
 testcases/network/sctp/sctp01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/network/sctp/sctp01.sh +1 -1
index bf13521c2..c4149af19 100755
@@ -58,6 +58,6 @@ test_run()
 
 setup
 test_run
-test_run -A 65000
+test_run '-A 65000'
 
 tst_exit
Signature · 1 line
2.16.3
#1 lore raw

PATCH 1/1 net/sctp: Fix parsing input variables in dash

Hi!

Quoted 3 lines

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.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 net/sctp: Fix parsing input variables in dash

Hi Cyril,

Quoted 31 lines

Hi!

Quoted 3 lines

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

	...
}
Quoted 5 lines

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