secure-env 0.2.2

Encrypted environment variables manager for your shell
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::collections::BTreeMap;

/// Render shell `export` lines that can be `eval`'d by the parent shell.
/// Values are single-quoted and embedded quotes are escaped for the shell.
pub fn export_lines(vars: &BTreeMap<String, String>) -> String {
    let mut out = String::new();
    for (key, value) in vars {
        let escaped = value.replace('\'', "'\\''");
        out.push_str(&format!("export {key}='{escaped}'\n"));
    }
    out
}