a1217668f55f9966d8da49b96bc2ce8fb38c2f5b
[openwrt/staging/mkresin.git] / package / network / utils / layerscape / restool / patches / 0006-scripts-use-strings-instead-of-arrays.patch
1 From 2127850302de2bd8dccff0e31415ce0218750773 Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Tue, 24 Oct 2017 16:29:53 +0000
4 Subject: [PATCH 06/12] scripts: use strings instead of arrays
5
6 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
7 ---
8 scripts/ls-main | 21 ++++++++++++++-------
9 1 file changed, 14 insertions(+), 7 deletions(-)
10
11 diff --git a/scripts/ls-main b/scripts/ls-main
12 index a39df2c..b0c742e 100755
13 --- a/scripts/ls-main
14 +++ b/scripts/ls-main
15 @@ -485,7 +485,9 @@ create_dpsw() {
16
17 # Make a link in case there is an end point specified
18 index=0
19 - for i in "${endpoint[@]}"; do
20 + echo "${endpoint}" |
21 + while read -r i
22 + do
23 connect $root_c "$dpsw.$index" "$i"
24 index=$((index + 1))
25 done
26 @@ -519,8 +521,8 @@ process_addsw() {
27 max_fdb_mc_groups=32
28 # dpsw object label
29 label=
30 - #Endpoint objects provided as argument
31 - endpoint=()
32 + # Endpoint objects provided as argument
33 + endpoint=
34 ifcnt=0
35 container=$root_c
36
37 @@ -559,7 +561,7 @@ process_addsw() {
38 container="${i#*=}"
39 ;;
40 @(dpni|dpmac).+([0-9]))
41 - endpoint[$ifcnt]="$(echo ${i#*=} | tr -d ,)"
42 + endpoint="${endpoint}"$'\n'"${i}"
43 ifcnt=$((ifcnt + 1))
44 ;;
45 *)
46 @@ -571,14 +573,19 @@ process_addsw() {
47 done
48
49 # Check if there are more endpoints provided than the number of the interfaces
50 - if [ $num_ifs -lt ${#endpoint[@]} ]; then
51 + if [ $num_ifs -lt $ifcnt ]; then
52 echo "Error: there are more endpoints provided than the number of the interfaces"
53 usage_addsw
54 exit 1
55 fi
56
57 + # Delete first empty line from the endpoint string
58 + endpoint="$(echo "${endpoint}" | tail -n +2)"
59 +
60 # Check if the endpoints are valid
61 - for i in "${endpoint[@]}"; do
62 + echo "${endpoint}" |
63 + while read -r i
64 + do
65 type_of_endpoint "$i"
66 check_endpoint "$i"
67 has_endpoint "$i"
68 @@ -592,7 +599,7 @@ process_addsw() {
69 if (( $object_exists_status == 1 )); then
70 echo "Created ETHSW object $dpsw with ${num_ifs} ports"
71
72 - if [ $num_ifs -gt ${#endpoint[@]} ]; then
73 + if [ $num_ifs -gt $ifcnt ]; then
74 echo "Do not forget to connect devices to interface(s)."
75 fi
76 fi
77 --
78 2.14.1
79