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

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