From 6e72eae061dd88ff6d871a6c9d657569b03888fa Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Oct 2021 20:57:33 +0100 Subject: subplotlib: Do not override environment entirely As per the Python template, do not override the full environment Signed-off-by: Daniel Silverstone --- subplotlib/src/steplibrary/runcmd.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subplotlib/src/steplibrary/runcmd.rs b/subplotlib/src/steplibrary/runcmd.rs index 7075b68..2bf8c56 100644 --- a/subplotlib/src/steplibrary/runcmd.rs +++ b/subplotlib/src/steplibrary/runcmd.rs @@ -46,8 +46,13 @@ impl ContextElement for Runcmd { self.env.drain(); self.paths.drain(..); self.env.insert("SHELL".into(), "/bin/sh".into()); - self.env - .insert("PATH".into(), env::join_paths(DEFAULT_PATHS.iter())?); + self.env.insert( + "PATH".into(), + env::var_os("PATH") + .map(Ok) + .unwrap_or_else(|| env::join_paths(DEFAULT_PATHS.iter()))?, + ); + // Having assembled the 'default' environment, override it with injected // content from the calling environment. for (k, v) in env::vars_os() { @@ -125,7 +130,6 @@ pub fn try_to_run_in(context: &ScenarioContext, dirname: &str, argv0: &str, args let mut proc = Command::new(argv0); proc.args(&shell_words::split(args)?); proc.current_dir(&datadir); - proc.env_clear(); proc.env("HOME", &datadir); proc.env("TMPDIR", &datadir); -- cgit v1.2.1