Skip to content

Commit eb5b6b5

Browse files
rscharfettaylorr
authored andcommitted
replace and remove run_command_v_opt_cd_env()
run_command_v_opt_cd_env() is only used in an example in a comment. Use the struct child_process member "env" and run_command() directly instead and then remove the unused convenience function. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 0e90673 commit eb5b6b5

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

run-command.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,19 +1006,14 @@ int run_command(struct child_process *cmd)
10061006

10071007
int run_command_v_opt(const char **argv, int opt)
10081008
{
1009-
return run_command_v_opt_cd_env(argv, opt, NULL, NULL);
1009+
return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, NULL);
10101010
}
10111011

10121012
int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class)
10131013
{
10141014
return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, tr2_class);
10151015
}
10161016

1017-
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
1018-
{
1019-
return run_command_v_opt_cd_env_tr2(argv, opt, dir, env, NULL);
1020-
}
1021-
10221017
int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
10231018
const char *const *env, const char *tr2_class)
10241019
{

run-command.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct child_process {
151151

152152
/**
153153
* The functions: start_command, finish_command, run_command,
154-
* run_command_v_opt, run_command_v_opt_cd_env do the following:
154+
* run_command_v_opt do the following:
155155
*
156156
* - If a system call failed, errno is set and -1 is returned. A diagnostic
157157
* is printed.
@@ -249,7 +249,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class);
249249
* env (the environment) is to be formatted like environ: "VAR=VALUE".
250250
* To unset an environment variable use just "VAR".
251251
*/
252-
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env);
253252
int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
254253
const char *const *env, const char *tr2_class);
255254

tmp-objdir.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
*
1111
* Example:
1212
*
13+
* struct child_process child = CHILD_PROCESS_INIT;
1314
* struct tmp_objdir *t = tmp_objdir_create("incoming");
14-
* if (!run_command_v_opt_cd_env(cmd, 0, NULL, tmp_objdir_env(t)) &&
15-
* !tmp_objdir_migrate(t))
15+
* strvec_push(&child.args, cmd);
16+
* strvec_pushv(&child.env, tmp_objdir_env(t));
17+
* if (!run_command(&child)) && !tmp_objdir_migrate(t))
1618
* printf("success!\n");
1719
* else
1820
* die("failed...tmp_objdir will clean up for us");

0 commit comments

Comments
 (0)