fix(listmailuser): Don't parse comments when reading config (#2617)
* fix(listmailuser): Don't parse comments Avoids passing comments to `dovecot_quota_to_hr()` which fails to handle it and would throws errors. * chore: Move config filter method to `helpers/utils.sh`
This commit is contained in:
parent
40e2d88482
commit
1f3e672018
|
@ -47,6 +47,7 @@ do
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
done < "${DATABASE}"
|
done < <(_filter_to_valid_lines "${DATABASE}")
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -5,8 +5,16 @@ function _escape
|
||||||
echo "${1//./\\.}"
|
echo "${1//./\\.}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if string input is an empty line, only whitespaces
|
# Returns input after filtering out lines that are:
|
||||||
# or `#` as the first non-whitespace character.
|
# empty, white-space, comments (`#` as the first non-whitespace character)
|
||||||
|
function _filter_to_valid_lines
|
||||||
|
{
|
||||||
|
grep --extended-regexp --invert-match "^\s*$|^\s*#" "${1}" || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: Only used by `relay.sh`, will be removed in future.
|
||||||
|
# Similar to _filter_to_valid_lines, but only returns a status code
|
||||||
|
# to indicate invalid line(s):
|
||||||
function _is_comment
|
function _is_comment
|
||||||
{
|
{
|
||||||
grep -q -E "^\s*$|^\s*#" <<< "${1}"
|
grep -q -E "^\s*$|^\s*#" <<< "${1}"
|
||||||
|
|
Loading…
Reference in New Issue