[PATCH 4/5] Make splitsep work as documented with less vars than fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 1ecd286..e10a34d 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
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux