Blame SOURCES/0153-lsinitrd.sh-prevent-construct.patch

a56a5e
From 7031115695bf014f39b4efc32a3e71a11daebfbc Mon Sep 17 00:00:00 2001
966cef
From: Harald Hoyer <harald@redhat.com>
966cef
Date: Thu, 27 Mar 2014 09:27:53 +0100
966cef
Subject: [PATCH] lsinitrd.sh: prevent < <$() construct
966cef
MIME-Version: 1.0
966cef
Content-Type: text/plain; charset=UTF-8
966cef
Content-Transfer-Encoding: 8bit
966cef
966cef
Running dracut in a chroot environment, which has /dev not correctly
966cef
setup will result in errors like:
966cef
966cef
/usr/bin/lsinitrd: line 164: /dev/fd/62: No such file or directory
966cef
cpio: Malformed number �5�OK��
966cef
cpio: Malformed number 5�OK��
966cef
cpio: Malformed number �OK��
966cef
966cef
This is because bash wants /dev/fd/<num> for constructs like:
966cef
foo < <$(bar)
966cef
---
966cef
 lsinitrd.sh | 49 +++++++++++++++++++++++++++++--------------------
966cef
 1 file changed, 29 insertions(+), 20 deletions(-)
966cef
966cef
diff --git a/lsinitrd.sh b/lsinitrd.sh
966cef
index 70e12f8..2fbebd8 100755
966cef
--- a/lsinitrd.sh
966cef
+++ b/lsinitrd.sh
966cef
@@ -160,27 +160,36 @@ case $bin in
966cef
         ;;
966cef
 esac
966cef
 
966cef
-if [[ $SKIP ]]; then
966cef
-    read -N 6 bin < <($SKIP "$image")
966cef
-fi
966cef
 
966cef
-case $bin in
966cef
-    $'\x1f\x8b'*)
966cef
-        CAT="zcat --";;
966cef
-    BZh*)
966cef
-        CAT="bzcat --";;
966cef
-    $'\x71\xc7'*|070701)
966cef
-        CAT="cat --"
966cef
-        ;;
966cef
-    $'\x04\x22'*)
966cef
-        CAT="lz4 -d -c";;
966cef
-    *)
966cef
-        CAT="xzcat --";
966cef
-        if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
966cef
-            CAT="xzcat --single-stream --"
966cef
-        fi
966cef
-        ;;
966cef
-esac
966cef
+CAT=$({
966cef
+        if [[ $SKIP ]]; then
966cef
+            $SKIP "$image"
966cef
+        else
966cef
+            cat "$image"
966cef
+        fi } | {
966cef
+        read -N 6 bin
966cef
+        case $bin in
966cef
+            $'\x1f\x8b'*)
966cef
+                echo "zcat --"
966cef
+                ;;
966cef
+            BZh*)
966cef
+                echo "bzcat --"
966cef
+                ;;
966cef
+            $'\x71\xc7'*|070701)
966cef
+                echo "cat --"
966cef
+                ;;
966cef
+            $'\x04\x22'*)
966cef
+                echo "lz4 -d -c"
966cef
+                ;;
966cef
+            *)
966cef
+                if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
966cef
+                    echo "xzcat --single-stream --"
966cef
+                else
966cef
+                    echo "xzcat --"
966cef
+                fi
966cef
+                ;;
966cef
+        esac
966cef
+    })
966cef
 
966cef
 skipcpio()
966cef
 {