Skip to main content

bash_exec_with_state

Function bash_exec_with_state 

Source
pub fn bash_exec_with_state(command: &str, state_path: &Path) -> i32
Expand description

Execute a command through bash with state file persistence.

Before running the command, sources the state file to restore previous exported variables. After running, saves the new environment to the state file and prints the diff as fish commands.

Returns the bash command’s exit code.

§Examples

use std::path::Path;
use reef::passthrough::bash_exec_with_state;

let state = Path::new("/tmp/reef-state-12345");
let exit_code = bash_exec_with_state("export FOO=bar", state);
// FOO=bar is persisted to the state file for next invocation