]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Allow setting empty environment variables
authorGeorges Discry <georges@discry.be>
Sun, 23 Apr 2023 12:47:44 +0000 (14:47 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 23 Apr 2023 18:41:36 +0000 (20:41 +0200)
Trying to set an empty environment variable with `FOO=` would instead
pass the `FOO` variable from the host, which is the expected behavior
when `=` is missing.

mkosi/__init__.py

index 5a66cba1ee48371e0acaf9001f2e265611c6e24f..f6352455b17eddcb59b1153d73c3a636f7a81907 100644 (file)
@@ -1210,8 +1210,8 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
     if args.environment:
         env = {}
         for s in args.environment:
-            key, _, value = s.partition("=")
-            value = value or os.getenv(key, "")
+            key, sep, value = s.partition("=")
+            value = value if sep else os.getenv(key, "")
             env[key] = value
         args.environment = env
     else: