From 953ca5254a252b63be81e7ac3b69e8d4f76e6889 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 18 Sep 2024 17:09:11 +0100 Subject: [PATCH] Avoid duplicate paths when path injection (#407) --- src/ansible_compat/runtime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ansible_compat/runtime.py b/src/ansible_compat/runtime.py index 31f95666..a7b9acab 100644 --- a/src/ansible_compat/runtime.py +++ b/src/ansible_compat/runtime.py @@ -922,7 +922,8 @@ def _update_env(self, varname: str, value: list[str], default: str = "") -> None return orig_value = self.environ.get(varname, default) if orig_value: - value = [*value, *orig_value.split(":")] + # we just want to avoid repeating the same entries, but order is important + value = list(dict.fromkeys([*value, *orig_value.split(":")])) value_str = ":".join(value) if value_str != self.environ.get(varname, ""): self.environ[varname] = value_str