Skip to main content

secure_env/
inject.rs

1use std::collections::BTreeMap;
2
3/// Render shell `export` lines that can be `eval`'d by the parent shell.
4/// Values are single-quoted and embedded quotes are escaped for the shell.
5pub fn export_lines(vars: &BTreeMap<String, String>) -> String {
6    let mut out = String::new();
7    for (key, value) in vars {
8        let escaped = value.replace('\'', "'\\''");
9        out.push_str(&format!("export {key}='{escaped}'\n"));
10    }
11    out
12}