summaryrefslogtreecommitdiff
path: root/package/base-files
diff options
context:
space:
mode:
authorMike Baker <mbm@openwrt.org>2006-11-20 19:30:50 +0000
committerMike Baker <mbm@openwrt.org>2006-11-20 19:30:50 +0000
commit9232f4adad2aa9e3ec89498f21fbc2d1f77938cd (patch)
treedc5e520c89795c8ccdc1e13c19205f2b82a525c1 /package/base-files
parentd28e34c34a44afe72be59300d7773bc91e6e2388 (diff)
downloadmtk-20170518-9232f4adad2aa9e3ec89498f21fbc2d1f77938cd.zip
mtk-20170518-9232f4adad2aa9e3ec89498f21fbc2d1f77938cd.tar.gz
mtk-20170518-9232f4adad2aa9e3ec89498f21fbc2d1f77938cd.tar.bz2
strtok helper function
SVN-Revision: 5592
Diffstat (limited to 'package/base-files')
-rwxr-xr-xpackage/base-files/default/etc/functions.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/package/base-files/default/etc/functions.sh b/package/base-files/default/etc/functions.sh
index f7cb878..aa5b000 100755
--- a/package/base-files/default/etc/functions.sh
+++ b/package/base-files/default/etc/functions.sh
@@ -118,3 +118,27 @@ find_mtd_part() {
echo "${PART:+/dev/mtdblock/$PART}"
}
+strtok() { # <string> <variable> [<separator>] ...
+ local right
+ local left="$1"
+ local count=0
+
+ shift
+
+ while [ $# -gt 1 ]; do
+ right="${left%%$2*}"
+
+ [ "$right" = "$left" ] && break
+
+ left="${left#$right$2}"
+
+ export $1="$right"; count=$((count+1))
+ shift 2
+ done
+
+ if [ $# -gt 0 -a "$left" ]; then
+ export $1="$left"; count=$((count+1))
+ fi
+
+ return $count
+}