refactor: Helper function `_replace_by_env_in_file()` by polarathene · Pull Request #3526 · docker-mailserver/docker-mailserver

added 2 commits

September 4, 2023 11:48
Minor change to add support for usage with `saslauthd.conf` which differs with `:` for it's key/value delimiter.

Also adopts the`_escape_for_sed()` method, instead of the inline sed pattern (_which for some reason escaped `=` but not `(` + `)`, thus buggy if ever matching on input with those tokens_).

`_escape_for_sed()` likewise wasn't escaping for `(` + `)` or even `|`, which are required for proper escape support if using `sed -E` / `sed -r` with this method. Additionally added escaping support for `&` replacement segment token, which seems valid. Increased verbosity to better grok pattern matching expression, clarified escaping concern with `sed` delimiter since the project is not consistent there.
No need to check for a non-empty value to prepend a space (_since an empty value is used via sed anyway?_).

Can also be a bit DRY with the sed pattern, matching the key + delimiter (_and all white-space before/after the delimiter until the value_), then capture that for the replacement left-side value while only actually swapping the value for the ENV input value.

Should be an improvement, unless there is a scenario that would differ between `` and ` ` as valid value assignments?

georglauterbach

georglauterbach

casperklein

@polarathene @casperklein

Both should be improvements for usage

Co-authored-by: Casper <casperklein@users.noreply.github.com>

@github-actions github-actions bot added the meta/stale

This issue / PR has become stale and will be closed if there is no further activity

label

Oct 2, 2023

@polarathene polarathene added stale-bot/ignore

Indicates that this issue / PR shall not be closed by our stale-checking CI

and removed meta/stale

This issue / PR has become stale and will be closed if there is no further activity

labels

Oct 2, 2023

casperklein