aboutsummaryrefslogtreecommitdiffstats
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
commit0a8080407b530a1ac2daa33ee61871568b498588 (patch)
treedd43e6d9ba3b123ea3fbe594443cab66eded6964 /package/base-files
parent1628ad2a553c2cc4d2a5fae87409c9dc9ace2dbc (diff)
downloadupstream-0a8080407b530a1ac2daa33ee61871568b498588.tar.gz
upstream-0a8080407b530a1ac2daa33ee61871568b498588.tar.bz2
upstream-0a8080407b530a1ac2daa33ee61871568b498588.zip
strtok helper function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5592 3c298f89-4303-0410-b956-a3cf2f4a3e73
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 f7cb878bc9..aa5b000644 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
+}