There is really no point in declaring a variable which is used just once. Also mark function local variables as such to make sure they don't overwrite global ones. Signed-off-by: Phil Sutter <phil@xxxxxx> --- tests/shell/testcases/chains/0021prio_0 | 45 +++++++++---------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/tests/shell/testcases/chains/0021prio_0 b/tests/shell/testcases/chains/0021prio_0 index b6647ac24ad10..82f52e33cc2af 100755 --- a/tests/shell/testcases/chains/0021prio_0 +++ b/tests/shell/testcases/chains/0021prio_0 @@ -3,7 +3,7 @@ set -e format_offset () { - i=$1 + local i=$1 if ((i == 0)) then echo "" @@ -16,21 +16,21 @@ format_offset () { } chainname () { - hook=$1 - prioname=$2 - priooffset=$3 + local hook=$1 + local prioname=$2 + local priooffset=$3 echo "${hook}${prioname}${priooffset}" | tr "\-+" "mp" } gen_chains () { - family=$1 - hook=$2 - prioname=$3 + local family=$1 + local hook=$2 + local prioname=$3 for i in -11 -10 0 10 11 do - offset=`format_offset $i` + local offset=`format_offset $i` $NFT add chain $family x `chainname $hook $prioname $offset` "{ type filter hook $hook priority $prioname $offset; }" done } @@ -46,13 +46,8 @@ do done done - hook=prerouting - prioname=dstnat - gen_chains $family $hook $prioname - - hook=postrouting - prioname=srcnat - gen_chains $family $hook $prioname + gen_chains $family prerouting dstnat + gen_chains $family postrouting srcnat done @@ -60,8 +55,7 @@ family=arp $NFT add table $family x for hook in input output do - prioname=filter - gen_chains $family $hook $prioname + gen_chains $family $hook filter done @@ -79,18 +73,9 @@ family=bridge $NFT add table $family x for hook in prerouting input forward output postrouting do - prioname=filter - gen_chains $family $hook $prioname + gen_chains $family $hook filter done -hook=prerouting -prioname=dstnat -gen_chains $family $hook $prioname - -hook=output -prioname=out -gen_chains $family $hook $prioname - -hook=postrouting -prioname=srcnat -gen_chains $family $hook $prioname +gen_chains $family prerouting dstnat +gen_chains $family output out +gen_chains $family postrouting srcnat -- 2.19.0