From 35181b2c411954a96e3ed9a0ebc6ce470d037595 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Thu, 30 Apr 2020 15:45:31 +0200
Subject: [PATCH 207/220] 10_linux.in: fix early exit due error when reading
 petitboot version

The script uses bash's read built-in command to get the petitboot version
version, but this command has a non-zero exit status if the EOF is found.

Since the /sys/firmware/devicetree/base/ibm,firmware-versions/petitboot
string ends with a NUL character, use the empty string as read delimiter
to prevent the command to read to the end-of-file and exit with an error.

Resolves: rhbz#1827397

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
 util/grub.d/10_linux.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 847646b..09adfce 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -194,7 +194,7 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
       petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
 
       if test -e ${petitboot_path}; then
-          read -a petitboot_version < ${petitboot_path}
+          read -r -d '' petitboot_version < ${petitboot_path}
           petitboot_version="$(echo ${petitboot_version//v})"
           major_version="$(echo ${petitboot_version} | cut -d . -f1)"
           minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
-- 
1.8.3.1

