Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
glehmann committed Feb 10, 2024
1 parent 8697270 commit f626894
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ fn yaml_get<'a>(data: &'a sy::Value, keys: &[Key]) -> Result<&'a sy::Value> {
}

fn run_editor(editor: &str, temp_file: &std::path::Path) -> Result<()> {
let editor_process_res = Command::new(&editor).arg(&temp_file).spawn();
let editor_process_res = Command::new(editor).arg(temp_file).spawn();
let mut editor_process = match editor_process_res {
Ok(ep) => ep,
Err(err) => {
// if we can't use the editor string as a command, it may have arguments that we need to split
if let Some(ref editor_args) = shlex::split(&editor) {
if let Some(ref editor_args) = shlex::split(editor) {
if editor_args.is_empty() {
// we need at least on element, fallback to the previous error so that the user
// can see its editor value in th error message
return Err(err).path_ctx(&editor);
return Err(err).path_ctx(editor);
}
Command::new(&editor_args[0])
.args(&editor_args[1..])
.arg(&temp_file)
.arg(temp_file)
.spawn()
.path_ctx(&editor_args[0])?
} else {
// we can't split the editor string, so fallback to the previous error
return Err(err).path_ctx(&editor);
return Err(err).path_ctx(editor);
}
}
};
Expand Down

0 comments on commit f626894

Please sign in to comment.