]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
make splitsep preserve backslashes (RHBZ#851295)
authorWill Woods <wwoods@redhat.com>
Thu, 23 Aug 2012 20:56:01 +0000 (16:56 -0400)
committerHarald Hoyer <harald@redhat.com>
Fri, 24 Aug 2012 07:29:31 +0000 (09:29 +0200)
splitsep() would drop escapes from its inputs. For example:

  splitsep ':' 'first:middle:\e\s\c\a\p\e\d' a b c

gave a='first', b='middle', c='escaped'. Even worse:

  splitsep ':' '\e\s\c\a\p\e\d:middle:last' a b c

gave a='escaped', b='escaped', c='escaped:middle:last'.

This fixes the quoting so both calls return the values you'd expect
(e.g. 'first', 'middle', '\e\s\c\a\p\e\d').

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

index 381b4ddc4acc89462283ca77012368cfa77ae948..60b4cb17a430a5cf7c0db19bac85ec086a653349 100755 (executable)
@@ -271,12 +271,12 @@ splitsep() {
 
     while [ -n "$str" -a "$#" -gt 1 ]; do
         tmp="${str%%$sep*}"
-        eval "$1=${tmp}"
-        str="${str#$tmp}"
+        eval "$1='${tmp}'"
+        str="${str#"$tmp"}"
         str="${str#$sep}"
         shift
     done
-    [ -n "$str" -a -n "$1" ] && eval "$1=$str"
+    [ -n "$str" -a -n "$1" ] && eval "$1='$str'"
     debug_on
     return 0
 }