From 8de0567d10c5eb2c14eff6044f4059679cd22e60 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Mon, 31 Jan 2022 18:59:15 +0100 Subject: [PATCH] proxmox-boot: add get_first_line_from_file helper and use it Signed-off-by: Stoiko Ivanov --- proxmox-boot/functions | 8 ++++++++ proxmox-boot/zz-proxmox-boot | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/proxmox-boot/functions b/proxmox-boot/functions index 6e19c20..4515a2d 100755 --- a/proxmox-boot/functions +++ b/proxmox-boot/functions @@ -101,3 +101,11 @@ loop_esp_list() { "$@" done } + +get_first_line() { + file="$1" + while IFS= read -r line || [ -n "$line" ]; do + break + done < "${file}" + echo "$line" +} diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot index 90d4aa9..db73166 100755 --- a/proxmox-boot/zz-proxmox-boot +++ b/proxmox-boot/zz-proxmox-boot @@ -46,9 +46,7 @@ update_esps() { fi if [ -f /etc/kernel/cmdline ]; then # we can have cmdline files with multiple or no new line at all, handle both! - while IFS= read -r CMDLINE || [ -n "$CMDLINE" ]; do - break - done < /etc/kernel/cmdline + CMDLINE=$(get_first_line /etc/kernel/cmdline) echo ${CMDLINE} | grep -q 'root=' || \ { warn "No root= parameter in /etc/kernel/cmdline found!"; exit 1; } else