Skip to content

Commit

Permalink
launch_editor: refactor to use start/finish_command
Browse files Browse the repository at this point in the history
The launch_editor function uses the convenient run_command_*
interface. Let's use the more flexible start_command and
finish_command functions, which will let us manipulate the
parent state while we're waiting for the child to finish.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 2, 2012
1 parent 1327452 commit f42ca31
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en

if (strcmp(editor, ":")) {
const char *args[] = { editor, path, NULL };
struct child_process p;

if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
memset(&p, 0, sizeof(p));
p.argv = args;
p.env = env;
p.use_shell = 1;
if (start_command(&p) < 0)
return error("unable to start editor '%s'", editor);

if (finish_command(&p))
return error("There was a problem with the editor '%s'.",
editor);
}
Expand Down

0 comments on commit f42ca31

Please sign in to comment.