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
parent
e173f0b384
commit
f7cadaa843
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue