mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-02-03 21:51:07 +02:00
strtok helper function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5592 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
b6fee4a3b3
commit
4fae1f4d2d
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user