read_variable + read_numerical_variable: keep the last found value only

This commit is contained in:
Jérémy Lecour 2022-05-02 10:21:22 +02:00 committed by Jérémy Lecour
parent 9745d78a16
commit d2daef52d9
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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
}