use xshell::cmd;
fn main() {
let x = (false).then_some("-s").unwrap_or_default();
let y = (false).then_some("-b").unwrap_or_default();
let sh = xshell::Shell::new().unwrap();
cmd!(sh, "git status {x} {y}").run().unwrap();
}
Error
$ git status
fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths
thread 'main' panicked at src/main.rs:7:42:
called `Result::unwrap()` on an `Err` value: command exited with non-zero code `git status `: 128
Despite the fact git status is a valid command, as is git status -s -b
But this will not:
use xshell::cmd;
fn main() {
let x = (false).then_some("-s").unwrap_or_default();
let y = (false).then_some("-b").unwrap_or_default();
let sh = xshell::Shell::new().unwrap();
cmd!(sh, "git status").run().unwrap();
}
Ran into this bug when working on Bevy Game Engine, where the same thing caused issues with a cargo test. Except the error was:
command exited with non-zero code `cargo test --workspace --lib --bins --tests --benches `: 1
error: unexpected argument '' found
This could will result in an error:
Error
Despite the fact
git status
is a valid command, as isgit status -s -b
But this will not:
Ran into this bug when working on Bevy Game Engine, where the same thing caused issues with a
cargo test
. Except the error was: