Skip to content

Commit f42ca31

Browse files
peffgitster
authored andcommitted
launch_editor: refactor to use start/finish_command
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1327452 commit f42ca31

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

editor.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
3737

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

41-
if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
42+
memset(&p, 0, sizeof(p));
43+
p.argv = args;
44+
p.env = env;
45+
p.use_shell = 1;
46+
if (start_command(&p) < 0)
47+
return error("unable to start editor '%s'", editor);
48+
49+
if (finish_command(&p))
4250
return error("There was a problem with the editor '%s'.",
4351
editor);
4452
}

0 commit comments

Comments
 (0)