]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
lsinitrd.sh: prevent < <$() construct
authorHarald Hoyer <harald@redhat.com>
Thu, 27 Mar 2014 08:27:53 +0000 (09:27 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 29 Jul 2014 09:52:07 +0000 (11:52 +0200)
Running dracut in a chroot environment, which has /dev not correctly
setup will result in errors like:

/usr/bin/lsinitrd: line 164: /dev/fd/62: No such file or directory
cpio: Malformed number �5�OK��
cpio: Malformed number 5�OK��
cpio: Malformed number �OK��

This is because bash wants /dev/fd/<num> for constructs like:
foo < <$(bar)

lsinitrd.sh

index 70e12f81cd9d66c5143965e920fe25f96f603b32..2fbebd8e3173ee8a63989edb4a2bf5c1eca1956c 100755 (executable)
@@ -160,27 +160,36 @@ case $bin in
         ;;
 esac
 
-if [[ $SKIP ]]; then
-    read -N 6 bin < <($SKIP "$image")
-fi
 
-case $bin in
-    $'\x1f\x8b'*)
-        CAT="zcat --";;
-    BZh*)
-        CAT="bzcat --";;
-    $'\x71\xc7'*|070701)
-        CAT="cat --"
-        ;;
-    $'\x04\x22'*)
-        CAT="lz4 -d -c";;
-    *)
-        CAT="xzcat --";
-        if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
-            CAT="xzcat --single-stream --"
-        fi
-        ;;
-esac
+CAT=$({
+        if [[ $SKIP ]]; then
+            $SKIP "$image"
+        else
+            cat "$image"
+        fi } | {
+        read -N 6 bin
+        case $bin in
+            $'\x1f\x8b'*)
+                echo "zcat --"
+                ;;
+            BZh*)
+                echo "bzcat --"
+                ;;
+            $'\x71\xc7'*|070701)
+                echo "cat --"
+                ;;
+            $'\x04\x22'*)
+                echo "lz4 -d -c"
+                ;;
+            *)
+                if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
+                    echo "xzcat --single-stream --"
+                else
+                    echo "xzcat --"
+                fi
+                ;;
+        esac
+    })
 
 skipcpio()
 {