aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/layerscape/restool/patches/0006-scripts-use-strings-instead-of-arrays.patch
blob: a1217668f55f9966d8da49b96bc2ce8fb38c2f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 2127850302de2bd8dccff0e31415ce0218750773 Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Tue, 24 Oct 2017 16:29:53 +0000
Subject: [PATCH 06/12] scripts: use strings instead of arrays

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 scripts/ls-main | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/scripts/ls-main b/scripts/ls-main
index a39df2c..b0c742e 100755
--- a/scripts/ls-main
+++ b/scripts/ls-main
@@ -485,7 +485,9 @@ create_dpsw() {
 
 	# Make a link in case there is an end point specified
 	index=0
-	for i in "${endpoint[@]}"; do
+	echo "${endpoint}" |
+	while read -r i
+	do
 		connect $root_c "$dpsw.$index" "$i"
 		index=$((index + 1))
 	done
@@ -519,8 +521,8 @@ process_addsw() {
 	max_fdb_mc_groups=32
 	# dpsw object label
 	label=
-	#Endpoint objects provided as argument
-	endpoint=()
+	# Endpoint objects provided as argument
+	endpoint=
 	ifcnt=0
 	container=$root_c
 
@@ -559,7 +561,7 @@ process_addsw() {
 				container="${i#*=}"
 				;;
 			@(dpni|dpmac).+([0-9]))
-				endpoint[$ifcnt]="$(echo ${i#*=} | tr -d ,)"
+				endpoint="${endpoint}"$'\n'"${i}"
 				ifcnt=$((ifcnt + 1))
 				;;
 			*)
@@ -571,14 +573,19 @@ process_addsw() {
 	done
 
 	# Check if there are more endpoints provided than the number of the interfaces
-	if [ $num_ifs -lt ${#endpoint[@]} ]; then
+	if [ $num_ifs -lt $ifcnt ]; then
 		echo "Error: there are more endpoints provided than the number of the interfaces"
 		usage_addsw
 		exit 1
 	fi
 
+	# Delete first empty line from the endpoint string
+	endpoint="$(echo "${endpoint}" | tail -n +2)"
+
 	# Check if the endpoints are valid
-	for i in "${endpoint[@]}"; do
+	echo "${endpoint}" |
+	while read -r i
+	do
 		type_of_endpoint "$i"
 		check_endpoint "$i"
 		has_endpoint "$i"
@@ -592,7 +599,7 @@ process_addsw() {
 	if (( $object_exists_status == 1 )); then
 		echo "Created ETHSW object $dpsw with ${num_ifs} ports"
 
-		if [ $num_ifs -gt ${#endpoint[@]} ]; then
+		if [ $num_ifs -gt $ifcnt ]; then
 		    echo "Do not forget to connect devices to interface(s)."
 		fi
 	fi
-- 
2.14.1