[pve-devel] [PATCH pve-kernel-meta 2/5] proxmox-boot: add get_first_line_from_file helper and use it

Stoiko Ivanov s.ivanov at proxmox.com
Mon Jan 31 18:59:15 CET 2022


Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 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
-- 
2.30.2





More information about the pve-devel mailing list