pub fn bash_exec(command: &str) -> i32Expand description
Execute a command through bash with streaming output, then print environment changes as fish commands to stdout.
Returns the bash command’s exit code. The caller (fish) is expected to
pipe stdout through | source to apply environment changes.
How it works:
- Capture a “before” snapshot of the current environment
- Run the command in bash with stderr inherited (streams directly)
- Stdout is captured — the command output appears before our markers, and we print it back to the real stdout immediately
- After the markers, we parse the env dump
- Diff before/after and print fish
setcommands
§Examples
use reef::passthrough::bash_exec;
// Run a bash command and get its exit code
let exit_code = bash_exec("export MY_VAR=hello && echo done");
assert_eq!(exit_code, 0);
// Fish `set -gx MY_VAR hello` commands are printed to stdout