From cccf43067183638caba45457ecc084089eca8851 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sun, 10 May 2020 16:27:06 +0200 Subject: [PATCH] Use shell to spawn editor on Unix, so that they can accept parameters. Fix #245 --- src/edit.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/edit.rs b/src/edit.rs index 9290bfb..25d6377 100644 --- a/src/edit.rs +++ b/src/edit.rs @@ -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