1 From e1036011baf9204d5fe6dd74e5a65f95b9681ebd Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Tue, 24 Oct 2017 16:29:56 +0000
4 Subject: [PATCH 07/12] scripts: use Bourne shell's pattern matching
6 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
8 scripts/ls-main | 71 ++++++++++++++++++++++++++++-----------------------------
9 1 file changed, 35 insertions(+), 36 deletions(-)
11 diff --git a/scripts/ls-main b/scripts/ls-main
12 index b0c742e..a8b9573 100755
21 # Intercept the Ctrl+C command but do not interrupt execution
24 @@ -370,15 +368,16 @@ process_addmux() {
28 - *(dprc.+([0-9])/)dpmac.+([0-9]))
31 - *(dprc.+([0-9])/)dpni.+([0-9]))
37 + arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
38 + arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
39 + if [ "$i" = "$arg_dpmac" ] ||
40 + [ "$i" = "$arg_dpni" ]; then
49 @@ -560,14 +559,17 @@ process_addsw() {
53 - @(dpni|dpmac).+([0-9]))
54 - endpoint="${endpoint}"$'\n'"${i}"
55 - ifcnt=$((ifcnt + 1))
58 - echo "Error: $i argument is invalid"
61 + arg_dpmac="$(echo $i | grep -x -E "dpmac.[0-9]+" || true )"
62 + arg_dpni="$(echo $i | grep -x -E "dpni.[0-9]+" || true )"
63 + if [ "$i" = "$arg_dpmac" ] ||
64 + [ "$i" = "$arg_dpni" ]; then
67 + echo "Error: $i argument is invalid"
74 @@ -704,7 +706,8 @@ process_addni() {
78 - if [[ ! "$mac_addr" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
79 + mac_addr_valid="$(echo $mac_addr | grep -x -E "^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$" || true )"
80 + if [ "$mac_addr" != "$mac_addr_valid" ]; then
81 echo "Invalid MAC address: $mac_addr"
84 @@ -776,25 +779,21 @@ process_addni() {
88 - *(dprc.+([0-9])/)dpmac.+([0-9]))
92 - *(dprc.+([0-9])/)dpni.+([0-9]))
96 - *(dprc.+([0-9])/)dpdmux.+([0-9]).+([0-9]))
100 - *(dprc.+([0-9])/)dpsw.+([0-9]).+([0-9]))
107 + arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
108 + arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
109 + arg_dpdmux="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpdmux.[0-9]+.[0-9]+" || true )"
110 + arg_dpsw="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpsw.[0-9]+.[0-9]+" || true )"
111 + if [ "$i" = "$arg_dpmac" ] ||
112 + [ "$i" = "$arg_dpni" ] ||
113 + [ "$i" = "$arg_dpdmux" ] ||
114 + [ "$i" = "$arg_dpsw" ]; then