From ba4d2c8a24377dbb5a3972e6971354c9a0b4f7f5 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 2 Jan 2021 19:38:41 -0800 Subject: [PATCH] commands: respect $EDITOR from environment Until recently, we didn't have support for `.gitignore` files. That meant that editors (like Emacs) that leave backup files around were annoying to use, because you'd have to manually remove the backup file afterwards. For that reason, I had hard-coded the editor to be `pico`. Now we have support for `.gitignore` files, so we can start respecting the user's $EDITOR. --- src/commands.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index 7879d4e66..24ad5f3c7 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1139,7 +1139,12 @@ fn edit_description(repo: &ReadonlyRepo, description: &str) -> String { description_file.write_all(description.as_bytes()).unwrap(); } - let exit_status = Command::new("pico") + let editor = std::env::var("EDITOR").unwrap_or_else(|_| "pico".to_string()); + // Handle things like `EDITOR=emacs -nw` + let args: Vec<_> = editor.split(' ').collect(); + let editor_args = if args.len() > 1 { &args[1..] } else { &[] }; + let exit_status = Command::new(args[0]) + .args(editor_args) .arg(&description_file_path) .status() .expect("failed to run editor");