]> diplodocus.org Git - nmh/blobdiff - sbr/arglist.c
Rework multibyte test so it will calculate the width of all of the
[nmh] / sbr / arglist.c
index 1f85b7b29558acb592d1a5bbd585a041867d4228..8749a4b9c4f8595b5924aec22e2aae05957d9f96 100644 (file)
  *
  * - 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);
+    }
+}