Make splitsep work as documented with less vars than fields

According to its comment in dracut-lib.sh:

    splitsep ":" "one:all:the:rest" one two

should set two="all:the:rest". But there's no check to see if the
current field is the last field, so it just gets "all".
master
Will Woods 2012-04-05 13:01:38 -04:00 committed by Harald Hoyer
parent e173f0b384
commit f7cadaa843
1 changed files with 2 additions and 1 deletions

View File

@ -224,13 +224,14 @@ splitsep() {
local sep="$1"; local str="$2"; shift 2
local tmp

while [ -n "$str" -a -n "$*" ]; do
while [ -n "$str" -a "$#" -gt 1 ]; do
tmp="${str%%$sep*}"
eval "$1=${tmp}"
str="${str#$tmp}"
str="${str#$sep}"
shift
done
[ -n "$str" -a -n "$1" ] && eval "$1=$str"

return 0
}