23c1504059
restool is a user space application providing the ability to dynamically create and manage Layerscape DPAA2 containers and objects from Linux. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
126 lines
3.3 KiB
Diff
126 lines
3.3 KiB
Diff
From e1036011baf9204d5fe6dd74e5a65f95b9681ebd Mon Sep 17 00:00:00 2001
|
|
From: Ioana Ciornei <ioana.ciornei@nxp.com>
|
|
Date: Tue, 24 Oct 2017 16:29:56 +0000
|
|
Subject: [PATCH 07/12] scripts: use Bourne shell's pattern matching
|
|
|
|
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
|
|
---
|
|
scripts/ls-main | 71 ++++++++++++++++++++++++++++-----------------------------
|
|
1 file changed, 35 insertions(+), 36 deletions(-)
|
|
|
|
diff --git a/scripts/ls-main b/scripts/ls-main
|
|
index b0c742e..a8b9573 100755
|
|
--- a/scripts/ls-main
|
|
+++ b/scripts/ls-main
|
|
@@ -72,8 +72,6 @@
|
|
#
|
|
##
|
|
|
|
-shopt -s extglob
|
|
-
|
|
# Intercept the Ctrl+C command but do not interrupt execution
|
|
trap ' ' INT
|
|
|
|
@@ -370,15 +368,16 @@ process_addmux() {
|
|
-c=* | --container=*)
|
|
container="${i#*=}"
|
|
;;
|
|
- *(dprc.+([0-9])/)dpmac.+([0-9]))
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
- *(dprc.+([0-9])/)dpni.+([0-9]))
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
*)
|
|
- usage_addmux
|
|
- exit 1
|
|
+ arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
|
|
+ arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
|
|
+ if [ "$i" = "$arg_dpmac" ] ||
|
|
+ [ "$i" = "$arg_dpni" ]; then
|
|
+ endpoint="$i"
|
|
+ else
|
|
+ usage_addmux
|
|
+ exit 1
|
|
+ fi
|
|
;;
|
|
esac
|
|
done
|
|
@@ -560,14 +559,17 @@ process_addsw() {
|
|
-c=* | --container=*)
|
|
container="${i#*=}"
|
|
;;
|
|
- @(dpni|dpmac).+([0-9]))
|
|
- endpoint="${endpoint}"$'\n'"${i}"
|
|
- ifcnt=$((ifcnt + 1))
|
|
- ;;
|
|
*)
|
|
- echo "Error: $i argument is invalid"
|
|
- usage_addsw
|
|
- exit 1
|
|
+ arg_dpmac="$(echo $i | grep -x -E "dpmac.[0-9]+" || true )"
|
|
+ arg_dpni="$(echo $i | grep -x -E "dpni.[0-9]+" || true )"
|
|
+ if [ "$i" = "$arg_dpmac" ] ||
|
|
+ [ "$i" = "$arg_dpni" ]; then
|
|
+ endpoint="$i"
|
|
+ else
|
|
+ echo "Error: $i argument is invalid"
|
|
+ usage_addsw
|
|
+ exit 1
|
|
+ fi
|
|
;;
|
|
esac
|
|
done
|
|
@@ -704,7 +706,8 @@ process_addni() {
|
|
;;
|
|
--mac-addr=*)
|
|
mac_addr="${i#*=}"
|
|
- if [[ ! "$mac_addr" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
|
|
+ mac_addr_valid="$(echo $mac_addr | grep -x -E "^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$" || true )"
|
|
+ if [ "$mac_addr" != "$mac_addr_valid" ]; then
|
|
echo "Invalid MAC address: $mac_addr"
|
|
exit 1
|
|
fi
|
|
@@ -776,25 +779,21 @@ process_addni() {
|
|
-o=* | --options=*)
|
|
options="${i#*=}"
|
|
;;
|
|
- *(dprc.+([0-9])/)dpmac.+([0-9]))
|
|
- no_link=0
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
- *(dprc.+([0-9])/)dpni.+([0-9]))
|
|
- no_link=0
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
- *(dprc.+([0-9])/)dpdmux.+([0-9]).+([0-9]))
|
|
- no_link=0
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
- *(dprc.+([0-9])/)dpsw.+([0-9]).+([0-9]))
|
|
- no_link=0
|
|
- endpoint="${i#*=}"
|
|
- ;;
|
|
*)
|
|
- usage_addni
|
|
- exit 1
|
|
+ arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
|
|
+ arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
|
|
+ arg_dpdmux="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpdmux.[0-9]+.[0-9]+" || true )"
|
|
+ arg_dpsw="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpsw.[0-9]+.[0-9]+" || true )"
|
|
+ if [ "$i" = "$arg_dpmac" ] ||
|
|
+ [ "$i" = "$arg_dpni" ] ||
|
|
+ [ "$i" = "$arg_dpdmux" ] ||
|
|
+ [ "$i" = "$arg_dpsw" ]; then
|
|
+ no_link=0
|
|
+ endpoint="$i"
|
|
+ else
|
|
+ usage_addni
|
|
+ exit 1
|
|
+ fi
|
|
;;
|
|
esac
|
|
done
|
|
--
|
|
2.14.1
|
|
|