From 874ed2576dce3b9404d23b8f5e52d10daa4fdbc1 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 3 Apr 2026 17:41:04 +0100 Subject: [PATCH] common.sh: Handle single quotes in load_environment_var() This is used to read version.txt, which was written with single quotes when Jenkins reverted a build. These quotes were then erroneously written into /etc/os-release, which caused havoc. This has already been addressed in jenkins-os, but let's make this code more robust anyway. Fix this by grepping out the lines we need (in one go) and actually parsing them with Bash. Less safe, but we already parse version.txt with Bash in other places. Signed-off-by: James Le Cuirot --- common.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common.sh b/common.sh index 3dbb8040dc..f8b8ed2fff 100644 --- a/common.sh +++ b/common.sh @@ -296,12 +296,10 @@ load_environment_allowlist() { } load_environment_var() { - local file="$1" name value - shift - for name in "$@"; do - value=$(grep "^${name}=" "${file}" | sed 's|"||g') - [[ -n "${value}" ]] && export "${value}" - done + local file="$1"; shift + unset "${@}" + . <(grep -f <(printf "^%s=\n" "${@}") "${file}") + export "${@}" } # Find root of source tree