Re: [PATCH 10/10] run-command API: add and use a run_command_sv_opt()
From: René Scharfe <hidden>
Date: 2022-10-14 19:22:36
Am 14.10.22 um 17:40 schrieb Ævar Arnfjörð Bjarmason:
Add a run_command_sv_opt() convenience wrapper for run_command_v_opt(), as noted in the API documentation this is for the common case of wanting to construct a "struct strvec" to pass to run_command_v_opt(), and as it's a one-shot to strvec_clear() it afterwards.
Interesting idea. It wastes memory by allocating the argument vector twice, but for most call-sites this won't be noticeable. I suspect it might fit at least some of the use cases for run_command_l_opt() better, e.g. those that previously used a strvec or that need some flexibility.
quoted hunk ↗ jump to hunk
diff --git a/run-command.h b/run-command.h index 2b1fe3cde5c..639cee4f4fb 100644 --- a/run-command.h +++ b/run-command.h@@ -151,7 +151,7 @@ struct child_process { /** * The functions: child_process_init, start_command, finish_command, - * run_command, run_command_l_opt, run_command_v_opt, + * run_command, run_command_l_opt, run_command_v_opt, run_command_sv_opt, * child_process_clear do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic@@ -262,6 +262,24 @@ int run_command_v_opt(const char **argv, int opt); LAST_ARG_MUST_BE_NULL int run_command_l_opt(int opt, ...); +/** + * The run_command_sv_opt() function is a wrapper for + * run_command_v_opt(). It takes a "struct strvec *args" which + * similarly to run_command() (but not run_command_sv_opt()) will be
^^^^^^^^^^^^^^^^^^^^ Do you mean run_command_v_opt()? René