X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/294f27d638a359339f8a9bca36d3f693b6c40e0c..eee44c467bf31f198c73a51cab2f7e9d5a2ad47c:/sbr/arglist.c diff --git a/sbr/arglist.c b/sbr/arglist.c index 1f85b7b2..8749a4b9 100644 --- a/sbr/arglist.c +++ b/sbr/arglist.c @@ -25,10 +25,10 @@ * * - If there are no spaces or shell metacharacters in "command", then * take it as-is. - * - If there are spaces in command, space-split command string and - * append an argument list to it. + * - If there are spaces in command, space-split command string. * - If we have shell metacharacters, run the command using - * /bin/sh -c 'command "${@}"'. + * /bin/sh -c 'command "$@"'. In this case, any additional arguments + * appended to the arglist will be expanded by "$@". * * In all cases additional arguments can be added to the argv[] array. */ @@ -123,3 +123,22 @@ argsplit(char *command, char **file, int *argp) return argvarray; } + +/* + * Free our argument array + */ + +void +arglist_free(char *command, char **argvarray) +{ + int i; + + if (command != NULL) + free(command); + + if (argvarray != NULL) { + for (i = 0; argvarray[i] != NULL; i++) + free(argvarray[i]); + free(argvarray); + } +}