diff --git a/satellite/satellite.py b/satellite/satellite.py index ebd5c23..d3d70bb 100644 --- a/satellite/satellite.py +++ b/satellite/satellite.py @@ -66,8 +66,17 @@ def _load_dotenv() -> None: if key.startswith("export "): key = key[len("export "):].strip() val = val.strip() - if len(val) >= 2 and val[0] == val[-1] and val[0] in ("'", '"'): - val = val[1:-1] + if val[:1] in ("'", '"'): + # Gequotet: Inhalt bis zum schliessenden Quote, Rest (Kommentar) egal. + q = val[0] + end = val.find(q, 1) + val = val[1:end] if end != -1 else val[1:] + else: + # Ungequotet: Inline-Kommentar (Whitespace + #) abschneiden. + m = re.search(r"\s+#", val) + if m: + val = val[:m.start()] + val = val.strip() if key and key not in os.environ: os.environ[key] = val except Exception as exc: