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

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