Use shell to spawn editor on Unix, so that they can accept parameters. Fix #245

This commit is contained in:
Federico Terzi 2020-05-10 16:27:06 +02:00
parent 7622daafd2
commit cccf430671

View File

@ -43,9 +43,19 @@ pub fn open_editor(file_path: &Path) -> bool {
};
// Start the editor and wait for its termination
let status = Command::new(&editor)
.arg(file_path)
.spawn();
let status = if cfg!(target_os = "windows") {
Command::new(&editor)
.arg(file_path)
.spawn()
}else{
// On Unix, spawn the editor using the shell so that it can
// accept parameters. See issue #245
Command::new("/bin/bash")
.arg("-c")
.arg(format!("{} '{}'", editor, file_path.to_string_lossy()))
.spawn()
};
if let Ok(mut child) = status {
// Wait for the user to edit the configuration