Ensure command and args are provided correctly

This commit is contained in:
Matthias Beyer 2018-03-12 23:20:32 +01:00
parent b8c3f7f834
commit a23afa7772

View file

@ -467,11 +467,17 @@ impl<'a> Runtime<'a> {
})
.or(env::var("EDITOR").ok())
.map(|s| {debug!("Editing with '{}'", s); s})
.map(|s| {
let mut c = Command::new(s);
c.stdin(::std::process::Stdio::inherit());
.and_then(|s| {
let mut split = s.split(" ");
let command = split.next();
if command.is_none() {
return None
}
let mut c = Command::new(command.unwrap()); // secured above
c.args(split);
c.stdin(::std::process::Stdio::null());
c.stderr(::std::process::Stdio::inherit());
c
Some(c)
})
}