Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions files/docker/systemctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,9 +2148,9 @@ def read_env_part(self, env_part): # -> generate[ (name, value) ]
try:
for real_line in env_part.split("\n"):
line = real_line.strip()
for found in re.finditer(r'\s*("[\w_]+=[^"]*"|[\w_]+=\S*)', line):
for found in re.finditer(r'\s*("[\w_]+=[^"]*"|\'[\w_]+=[^\']*\'|[\w_]+=\S*)', line):
part = found.group(1)
if part.startswith('"'):
if part.startswith('"') or part.startswith("'"):
part = part[1:-1]
name, value = part.split("=", 1)
yield name, value
Expand Down
4 changes: 2 additions & 2 deletions files/docker/systemctl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,9 +2148,9 @@ def read_env_part(self, env_part): # -> generate[ (name, value) ]
try:
for real_line in env_part.split("\n"):
line = real_line.strip()
for found in re.finditer(r'\s*("[\w_]+=[^"]*"|[\w_]+=\S*)', line):
for found in re.finditer(r'\s*("[\w_]+=[^"]*"|\'[\w_]+=[^\']*\'|[\w_]+=\S*)', line):
part = found.group(1)
if part.startswith('"'):
if part.startswith('"') or part.startswith("'"):
part = part[1:-1]
name, value = part.split("=", 1)
yield name, value
Expand Down
12 changes: 9 additions & 3 deletions testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,7 @@ def test_2148_show_environment_from_some_bad_parts(self, real: bool = False) ->
self.coverage()
def test_2150_have_environment_with_multiple_parts(self) -> None:
""" check that the result of 'environment UNIT' can
list the assignements that are crammed into one line."""
list the assignments that are crammed into one line."""
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Environment=
testname = self.testname()
testdir = self.testdir()
Expand All @@ -2760,9 +2760,12 @@ def test_2150_have_environment_with_multiple_parts(self) -> None:
Description=Testing B
[Service]
EnvironmentFile=/etc/sysconfig/zzb.conf
Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6" 'VAR4=7 8'
Environment='VAR5='
Environment='VAR6=9 10'
ExecStart=/usr/bin/printf $DEF1 $DEF2 \
$VAR1 $VAR2 $VAR3
$VAR1 $VAR2 $VAR3 \
$VAR4 $VAR5
[Install]
WantedBy=multi-user.target""")
cmd = "{systemctl} environment zzb.service -vv"
Expand All @@ -2775,6 +2778,9 @@ def test_2150_have_environment_with_multiple_parts(self) -> None:
self.assertTrue(greps(out, r"^VAR1=word1 word2"))
self.assertTrue(greps(out, r"^VAR2=word3"))
self.assertTrue(greps(out, r"^VAR3=\$word 5 6"))
self.assertTrue(greps(out, r"^VAR4=7 8"))
self.assertTrue(greps(out, r"^VAR5="))
self.assertTrue(greps(out, r"^VAR6=9 10"))
a_lines = len(lines(out))
#
self.rm_testdir()
Expand Down