Skip to content

Commit bac8037

Browse files
peffgitster
authored andcommitted
editor: use run_command's shell feature
Now that run_command implements the same code in a more general form, we can make use of it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f445644 commit bac8037

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

editor.c

+2-19
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,9 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
3636
return error("Terminal is dumb, but EDITOR unset");
3737

3838
if (strcmp(editor, ":")) {
39-
size_t len = strlen(editor);
40-
int i = 0;
41-
int failed;
42-
const char *args[6];
43-
struct strbuf arg0 = STRBUF_INIT;
39+
const char *args[] = { editor, path, NULL };
4440

45-
if (strcspn(editor, "|&;<>()$`\\\"' \t\n*?[#~=%") != len) {
46-
/* there are specials */
47-
strbuf_addf(&arg0, "%s \"$@\"", editor);
48-
args[i++] = "sh";
49-
args[i++] = "-c";
50-
args[i++] = arg0.buf;
51-
}
52-
args[i++] = editor;
53-
args[i++] = path;
54-
args[i] = NULL;
55-
56-
failed = run_command_v_opt_cd_env(args, 0, NULL, env);
57-
strbuf_release(&arg0);
58-
if (failed)
41+
if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
5942
return error("There was a problem with the editor '%s'.",
6043
editor);
6144
}

0 commit comments

Comments
 (0)