@matheusbsbs / matheus-bagliano / commits / bac8037081
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 30, 2009 at 05:56 UTC bac8037081735a49bccdc3b3b1457129f9bcc451
1 file changed +2 -19
editor.c
+2 -19
@@ -36,26 +36,9 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
36 return error("Terminal is dumb, but EDITOR unset");
37
38 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 };
40
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))
42 return error("There was a problem with the editor '%s'.",
43 editor);
44 }