I was glad to have the Python equivalent of the shlex crate, which understands shell quoting, helping in transforming command arguments into what's suitable to send to process::Command::args. This allows one to avoid the pain experienced by naively doing the following:
let mut command = command.split(char::is_whitespace); let process::command::new(command.next().unwrap()) .args(command.collect::<Vec<_>>) .spawn() ...
If the command is something like hg commit --message 'git eat world', then the iterator would expand to:
That will not run, and will fail with a not-obvious error message. Using shlex, instead:
let mut command = shlex::split(args).unwrap()); let process::command::new(command.remove(1).unwrap()) .args(command) .spawn() ...
Output should then be like:
- git eat world
Just one contribution this week, and it's not even that great... not sure it's an improvement