pub fn build_shell_env_prefix(
env: Option<&[(String, String)]>,
) -> Result<String>Expand description
Builds the export KEY='value' && prefix that applies env to a shell command, or ""
when there is none.
export (rather than an env KEY=value wrapper) sets the variables in the shell itself, so
every stage of a pipeline inherits them, including the interpreter of
execute_code_streaming. Values are
shell_quoted; the trailing && keeps a surrounding
cd ... && <prefix><command> chain fail-fast.
use strands::sandbox::build_shell_env_prefix;
let env = [("FOO".to_owned(), "bar".to_owned())];
assert_eq!(build_shell_env_prefix(Some(&env[..]))?, "export FOO='bar' && ");
assert_eq!(build_shell_env_prefix(None)?, "");