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

Would the performance be the same with your library vs "std::process::Command" #18

Closed Joe23232 closed 3 years ago

Joe23232 commented 3 years ago
Command::new("sh")
    .arg("-c")
    .arg("echo \"%{l}Hello%{c}yellow%{r}Bar\" | lemonbar -p -F#ffffff -B#232323")
    .spawn()
    .expect("Error: connect run \"lemonbar\" Please ensure it is installed!");

If I were to run this exact same command into your library, would the performance be the same or is it literally using bash?

rust-shell-script commented 3 years ago

This library does not need to launch an additional bash process to run the commands and there is also no runtime parsing/interpreting comparing to bash, so it is expected that the performance will be better. However, performance is not what the library is focusing on. If you really care about it, you should not call any external commands.

BTW, bash script's performance is notorious bad: http://spencertipping.com/posts/2013.0814.bash-is-irrecoverably-broken.html.

Joe23232 commented 3 years ago

I see thanks mate.