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

run-command: convert simple callsites to use_shell

Now that we have the use_shell feature, these callsites can all be converted with small changes. 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:53 UTC ac0ba18df0c58decfb128336bab51a172c77abc0
4 files changed +10 -12
convert.c
+2 -1
@@ -249,10 +249,11 @@ static int filter_buffer(int fd, void *data)
249 struct child_process child_process;
250 struct filter_params *params = (struct filter_params *)data;
251 int write_err, status;
252 - const char *argv[] = { "sh", "-c", params->cmd, NULL };
252 + const char *argv[] = { params->cmd, NULL };
253
254 memset(&child_process, 0, sizeof(child_process));
255 child_process.argv = argv;
256 + child_process.use_shell = 1;
257 child_process.in = -1;
258 child_process.out = fd;
259
imap-send.c
+2 -6
@@ -965,17 +965,13 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
965 /* open connection to IMAP server */
966
967 if (srvc->tunnel) {
968 - const char *argv[4];
968 + const char *argv[] = { srvc->tunnel, NULL };
969 struct child_process tunnel = {0};
970
971 imap_info("Starting tunnel '%s'... ", srvc->tunnel);
972
973 - argv[0] = "sh";
974 - argv[1] = "-c";
975 - argv[2] = srvc->tunnel;
976 - argv[3] = NULL;
977 -
973 tunnel.argv = argv;
974 + tunnel.use_shell = 1;
975 tunnel.in = -1;
976 tunnel.out = -1;
977 if (start_command(&tunnel))
ll-merge.c
+3 -3
@@ -175,7 +175,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
175 { "B", temp[2] },
176 { NULL }
177 };
178 - const char *args[] = { "sh", "-c", NULL, NULL };
178 + const char *args[] = { NULL, NULL };
179 int status, fd, i;
180 struct stat st;
181
@@ -190,8 +190,8 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
190
191 strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
192
193 - args[2] = cmd.buf;
194 - status = run_command_v_opt(args, 0);
193 + args[0] = cmd.buf;
194 + status = run_command_v_opt(args, RUN_USING_SHELL);
195 fd = open(temp[1], O_RDONLY);
196 if (fd < 0)
197 goto bad;
pager.c
+3 -2
@@ -28,7 +28,7 @@ static void pager_preexec(void)
28 }
29 #endif
30
31 -static const char *pager_argv[] = { "sh", "-c", NULL, NULL };
31 +static const char *pager_argv[] = { NULL, NULL };
32 static struct child_process pager_process;
33
34 static void wait_for_pager(void)
@@ -81,7 +81,8 @@ void setup_pager(void)
81 spawned_pager = 1; /* means we are emitting to terminal */
82
83 /* spawn the pager */
84 - pager_argv[2] = pager;
84 + pager_argv[0] = pager;
85 + pager_process.use_shell = 1;
86 pager_process.argv = pager_argv;
87 pager_process.in = -1;
88 if (!getenv("LESS")) {