]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Make splitsep work as documented with less vars than fields
authorWill Woods <wwoods@redhat.com>
Thu, 5 Apr 2012 17:01:38 +0000 (13:01 -0400)
committerHarald Hoyer <harald@redhat.com>
Mon, 16 Apr 2012 09:53:04 +0000 (11:53 +0200)
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".

modules.d/99base/dracut-lib.sh

index 1ecd28666678d00d43d075680b1a79ef5ddf8d97..e10a34d6ae6a8e3d4b1fa50ae8d895ebfaa89bb6 100755 (executable)
@@ -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
 }