ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Martin von Zweigbergk 2021-01-02 19:38:41 -08:00
parent d7b9bd55e8
commit ba4d2c8a24

View file

@ -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");