Open piotrp opened 2 weeks ago
I did a quick test and looks like this read_env_part
implementation works better:
for found in re.finditer(r'\s*("[\w_]+=[^"]*"|[\w_]+=\S*)', env_part.strip()):
part = found.group(1)
if part.startswith('"'):
part = part[1:-1]
name, value = part.split("=", 1)
yield name, value.replace("\\\n", "")
Replacing at the end is needed because \
at the end of line is meant to remove the newline character and join lines.
I am trying to use systemctl3.py with services that need long environment variables with newlines, and I noticed that newlines aren't supported.
Example from my service:
A shorter standalone test case:
Output logged after starting this service:
A quick test with additional logging in
read_env_part
(logg.info("env part: %s", env_part)
) shows that the value is read correctly, and the only issue is with the way thatread_env_part
interprets this data: