From cfce7fff6fd0c8f40efd2f54cf78fde043844cc1 Mon Sep 17 00:00:00 2001 From: leoca Date: Sun, 13 Sep 2026 05:53:40 +0200 Subject: [PATCH 1/2] fix: escape single quotes in forwarded env values 340d9ab wrapped the injected values in single quotes so that spaces survive `source`, but a value that itself contains a single quote still closes the quoting early. The env file then fails to source with "unexpected EOF while looking for matching `''", and the benchmark never runs. The values come from `--profile-folder` and the user's PATH, so a profile folder like "/tmp/it's here" is enough to break walltime and memory runs. Escape embedded quotes as '\'' so the value is passed through verbatim. --- src/executor/helpers/run_with_env.rs | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/executor/helpers/run_with_env.rs b/src/executor/helpers/run_with_env.rs index 6af3eb887..39d06d2f3 100644 --- a/src/executor/helpers/run_with_env.rs +++ b/src/executor/helpers/run_with_env.rs @@ -61,7 +61,7 @@ fn create_env_file(extra_env: &HashMap) -> Result let system_env = get_exported_system_env()?; let base_injected_env = extra_env .iter() - .map(|(k, v)| format!("export {k}='{v}'")) + .map(|(k, v)| format!("export {k}='{}'", v.replace('\'', r"'\''"))) .collect::>() .join("\n"); @@ -70,3 +70,31 @@ fn create_env_file(extra_env: &HashMap) -> Result env_file.write_all(format!("{system_env}\n{base_injected_env}").as_bytes())?; Ok(env_file) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_env_file_preserves_single_quotes() { + let value = "/tmp/it's a profile folder"; + let extra_env = HashMap::from([("CODSPEED_TEST_VALUE".to_string(), value.to_string())]); + let env_file = create_env_file(&extra_env).unwrap(); + + let output = Command::new("bash") + .arg("-c") + .arg(format!( + "source {} && printf %s \"$CODSPEED_TEST_VALUE\"", + env_file.path().display() + )) + .output() + .unwrap(); + + assert!( + output.status.success(), + "{}", + String::from_utf8_lossy(&output.stderr) + ); + assert_eq!(String::from_utf8_lossy(&output.stdout), value); + } +} From b9fd0b74834978f13c94cc6d50e9fd052bdd9434 Mon Sep 17 00:00:00 2001 From: Leo Camus Date: Sun, 13 Sep 2026 05:59:35 +0200 Subject: [PATCH 2/2] Update src/executor/helpers/run_with_env.rs Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/executor/helpers/run_with_env.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/executor/helpers/run_with_env.rs b/src/executor/helpers/run_with_env.rs index 39d06d2f3..97ee236ec 100644 --- a/src/executor/helpers/run_with_env.rs +++ b/src/executor/helpers/run_with_env.rs @@ -83,10 +83,9 @@ mod tests { let output = Command::new("bash") .arg("-c") - .arg(format!( - "source {} && printf %s \"$CODSPEED_TEST_VALUE\"", - env_file.path().display() - )) + .arg("source \"$1\" && printf %s \"$CODSPEED_TEST_VALUE\"") + .arg("bash") + .arg(env_file.path()) .output() .unwrap();