general-functions.pl: Refactor GetCoreUpdateVersion function

Message ID 20260218181301.5922-1-stefan.schantl@ipfire.org
State Accepted
Commit f7c80e81f64653148b834a137cb08043ef021a8a
Headers
Series general-functions.pl: Refactor GetCoreUpdateVersion function |

Commit Message

Stefan Schantl 18 Feb 2026, 6:13 p.m. UTC
There is no need for a loop when only grab the first line of a file
which only has one line. Also remove the newline from the grabbed line,
which may cause malfunctions on further processing.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/cfgroot/general-functions.pl | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Patch

diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl
index 1c3374d86..bcc8942c3 100644
--- a/config/cfgroot/general-functions.pl
+++ b/config/cfgroot/general-functions.pl
@@ -1058,11 +1058,9 @@  sub GetCoreUpdateVersion() {
 	my $core_update;
 
 	open(FILE, "/opt/pakfire/db/core/mine");
-	while (<FILE>) {
-		$core_update = $_;
-		last;
-	}
+	$core_update = <FILE>;
 	close(FILE);
+	chomp($core_update);
 
 	return $core_update;
 }