From d2daef52d9bd262862ce64119b8260a0a77ba9e8 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 2 May 2022 10:21:22 +0200 Subject: [PATCH] read_variable + read_numerical_variable: keep the last found value only --- server/CHANGELOG.md | 1 + server/lib/includes | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md index 8909a9f..98e7b12 100644 --- a/server/CHANGELOG.md +++ b/server/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed * shell syntax error when ${btrfs_bin} variable is empty +* read_variable + read_numerical_variable: keep the last found value only ### Security diff --git a/server/lib/includes b/server/lib/includes index 3892a2b..91321a3 100755 --- a/server/lib/includes +++ b/server/lib/includes @@ -445,7 +445,7 @@ read_variable() { pattern="^\s*${var_name}=.+" - grep --extended-regexp --only-matching "${pattern}" "${file}" | cut -d= -f2 + grep --extended-regexp --only-matching "${pattern}" "${file}" | tail -1 | cut -d= -f2 } read_numerical_variable() { @@ -454,5 +454,5 @@ read_numerical_variable() { pattern="^\s*${var_name}=-?[0-9]+" - grep --extended-regexp --only-matching "${pattern}" "${file}" | cut -d= -f2 + grep --extended-regexp --only-matching "${pattern}" "${file}" | tail -1 | cut -d= -f2 }