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 <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>

René Scharfe committed Oct 30, 2022 at 12:51 UTC eb5b6b57d0e9fba0e50871ece4ea79e76cd61a36
3 files changed +6 -10
run-command.c
+1 -6
@@ -1006,7 +1006,7 @@ int run_command(struct child_process *cmd)
1006
1007 int run_command_v_opt(const char **argv, int opt)
1008 {
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);
1010 }
1011
1012 int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class)
@@ -1014,11 +1014,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class)
1014 return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, tr2_class);
1015 }
1016
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 -
1017 int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
1018 const char *const *env, const char *tr2_class)
1019 {
run-command.h
+1 -2
@@ -151,7 +151,7 @@ struct child_process {
151
152 /**
153 * 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:
155 *
156 * - If a system call failed, errno is set and -1 is returned. A diagnostic
157 * is printed.
@@ -249,7 +249,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class);
249 * env (the environment) is to be formatted like environ: "VAR=VALUE".
250 * To unset an environment variable use just "VAR".
251 */
252 -int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env);
252 int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
253 const char *const *env, const char *tr2_class);
254
tmp-objdir.h
+4 -2
@@ -10,9 +10,11 @@
10 *
11 * Example:
12 *
13 + * struct child_process child = CHILD_PROCESS_INIT;
14 * 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))
18 * printf("success!\n");
19 * else
20 * die("failed...tmp_objdir will clean up for us");