Skip to content

Commit ac0ba18

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa7151a commit ac0ba18

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ static int filter_buffer(int fd, void *data)
249249
struct child_process child_process;
250250
struct filter_params *params = (struct filter_params *)data;
251251
int write_err, status;
252-
const char *argv[] = { "sh", "-c", params->cmd, NULL };
252+
const char *argv[] = { params->cmd, NULL };
253253

254254
memset(&child_process, 0, sizeof(child_process));
255255
child_process.argv = argv;
256+
child_process.use_shell = 1;
256257
child_process.in = -1;
257258
child_process.out = fd;
258259

imap-send.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -965,17 +965,13 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
965965
/* open connection to IMAP server */
966966

967967
if (srvc->tunnel) {
968-
const char *argv[4];
968+
const char *argv[] = { srvc->tunnel, NULL };
969969
struct child_process tunnel = {0};
970970

971971
imap_info("Starting tunnel '%s'... ", srvc->tunnel);
972972

973-
argv[0] = "sh";
974-
argv[1] = "-c";
975-
argv[2] = srvc->tunnel;
976-
argv[3] = NULL;
977-
978973
tunnel.argv = argv;
974+
tunnel.use_shell = 1;
979975
tunnel.in = -1;
980976
tunnel.out = -1;
981977
if (start_command(&tunnel))

ll-merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
175175
{ "B", temp[2] },
176176
{ NULL }
177177
};
178-
const char *args[] = { "sh", "-c", NULL, NULL };
178+
const char *args[] = { NULL, NULL };
179179
int status, fd, i;
180180
struct stat st;
181181

@@ -190,8 +190,8 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
190190

191191
strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
192192

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);
195195
fd = open(temp[1], O_RDONLY);
196196
if (fd < 0)
197197
goto bad;

pager.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void pager_preexec(void)
2828
}
2929
#endif
3030

31-
static const char *pager_argv[] = { "sh", "-c", NULL, NULL };
31+
static const char *pager_argv[] = { NULL, NULL };
3232
static struct child_process pager_process;
3333

3434
static void wait_for_pager(void)
@@ -81,7 +81,8 @@ void setup_pager(void)
8181
spawned_pager = 1; /* means we are emitting to terminal */
8282

8383
/* spawn the pager */
84-
pager_argv[2] = pager;
84+
pager_argv[0] = pager;
85+
pager_process.use_shell = 1;
8586
pager_process.argv = pager_argv;
8687
pager_process.in = -1;
8788
if (!getenv("LESS")) {

0 commit comments

Comments
 (0)