diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-08 20:57:33 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-13 19:43:07 +0100 |
commit | 6e72eae061dd88ff6d871a6c9d657569b03888fa (patch) | |
tree | 31f697725c0121a3bbee8766f209678c3d2a69ef /subplotlib | |
parent | 08aa8ad930c1488285263145f01c7e8a9dca59dc (diff) | |
download | subplot-6e72eae061dd88ff6d871a6c9d657569b03888fa.tar.gz |
subplotlib: Do not override environment entirely
As per the Python template, do not override the full environment
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r-- | subplotlib/src/steplibrary/runcmd.rs | 10 |
1 files 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); |