tests: Fix setconfig() and make more robust

This commit is contained in:
Jerome Charaoui 2018-07-15 00:48:39 -04:00
parent 57b2f217a8
commit 4dd6a0971d

View File

@ -68,9 +68,9 @@ teardown() {
}
setconfig() {
if grep -q "$2 =" "${BATS_TMPDIR}/$1"; then
sed -i "s/^$2.*/$2 = $3/" "${BATS_TMPDIR}/$1"
if grep -qe "$2\s\+=" "${BATS_TMPDIR}/$1"; then
sed -i "s/^$2\s\+=.*/$2 = $3/" "${BATS_TMPDIR}/$1"
else
echo "$2 = $3/" >> "${BATS_TMPDIR}/$1"
echo "$2 = $3" >> "${BATS_TMPDIR}/$1"
fi
}