From bac8037081735a49bccdc3b3b1457129f9bcc451 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Dec 2009 05:56:16 -0500 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- editor.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/editor.c b/editor.c index 615f5754d..d8340031d 100644 --- a/editor.c +++ b/editor.c @@ -36,26 +36,9 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en return error("Terminal is dumb, but EDITOR unset"); if (strcmp(editor, ":")) { - size_t len = strlen(editor); - int i = 0; - int failed; - const char *args[6]; - struct strbuf arg0 = STRBUF_INIT; + const char *args[] = { editor, path, NULL }; - if (strcspn(editor, "|&;<>()$`\\\"' \t\n*?[#~=%") != len) { - /* there are specials */ - strbuf_addf(&arg0, "%s \"$@\"", editor); - args[i++] = "sh"; - args[i++] = "-c"; - args[i++] = arg0.buf; - } - args[i++] = editor; - args[i++] = path; - args[i] = NULL; - - failed = run_command_v_opt_cd_env(args, 0, NULL, env); - strbuf_release(&arg0); - if (failed) + if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env)) return error("There was a problem with the editor '%s'.", editor); } -- 2.26.2