From: Will Woods Date: Thu, 5 Apr 2012 17:01:38 +0000 (-0400) Subject: Make splitsep work as documented with less vars than fields X-Git-Tag: 019~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7cadaa843498c4b986f8a030fab39002ad108b6;p=thirdparty%2Fdracut.git 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". --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 1ecd28666..e10a34d6a 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -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 }