rust-shell-script / rust_cmd_lib

Common rust command-line macros and utilities, to write shell-script like tasks in a clean, natural and rusty way
https://docs.rs/cmd_lib/
Apache License 2.0
1.05k stars 37 forks source link

nested `cd` does not work #50

Closed ikey4u closed 2 years ago

ikey4u commented 2 years ago

This is the minimal example to reproduce the problmen

Cargo.toml

[dependencies]
cmd_lib = "1.3"

main.rs

use cmd_lib::run_cmd;
fn main() {
    run_cmd! {
        mkdir -p build;
        cd build;
        mkdir -p nested;
        cd nested;
    }.unwrap();
}

Run the above code gives the followin error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "Running [\"cd\", \"nested\"] failed: cd nested: No such file or directory" }', src/main.rs:8:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace