mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
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 <jlecuirot@microsoft.com>
This commit is contained in:
parent
44bd310fb7
commit
874ed2576d
10
common.sh
10
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user