Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > I was experimenting with implementing a run_command_opt_l() earlier > which would give us the safety Jeff notes. The relevant end-state for > these two files is (there's more conversions, and I manually edited the > diff to remove an unrelated change): There still are some changes that would not belong here, but for the purpose of illustrating the usage of _l variant, this is good enough. Of course, if we want to follow the existing naming scheme, the new function must be called _l_opt(), not _opt_l(). _v_ in the _v_opt() comes from execv() and you are adding execl() analogue here. > - if (run_command_v_opt(argv.v, RUN_GIT_CMD)) { > + if (run_command_opt_l(RUN_GIT_CMD, "-C", repo, "sparse-checkout", > + "set", NULL)) { And this does give us protection from the "Programmers can give unterminated list to run_command_v_opt() by mistake", which is not really solved mechanically even if the list is prepared with the strvec API (because the compiler has to be smart enough to know that argv.v was prepared with proper use of the API), which is nice. Having to give the option flags as the first argument, of course it is necessary because we are talking about the _l variant with varargs, looks ugly, though. Also, I am not sure how useful this new function actually is. Many hits from my quick "grep" in the message you are responding to did use strvec because they wanted to dynamically build up the command line, and _l variant does not really shine in these places. We may probably be able to refactor some (but not all) of these sites so that the command line is not built dynamically with unknown number of elements in unknown order, but that feels like a solution looking for a problem, changing code to use the new function, tail wagging the dog. So, I dunno...