summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
Diffstat (limited to 'job.c')
-rw-r--r--job.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/job.c b/job.c
index d56bfe9..82612c0 100644
--- a/job.c
+++ b/job.c
@@ -2960,11 +2960,29 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
*t = '\0';
}
- new_argv = xmalloc (4 * sizeof (char *));
- new_argv[0] = xstrdup(shell);
- new_argv[1] = xstrdup(shellflags ? shellflags : "");
- new_argv[2] = line;
- new_argv[3] = NULL;
+ /* Create an argv list for the shell command line. */
+ {
+ int n = 0;
+
+ new_argv = xmalloc ((4 + sflags_len/2) * sizeof (char *));
+ new_argv[n++] = xstrdup (shell);
+
+ /* Chop up the shellflags (if any) and assign them. */
+ if (! shellflags)
+ new_argv[n++] = xstrdup ("");
+ else
+ {
+ const char *s = shellflags;
+ char *t;
+ unsigned int len;
+ while ((t = find_next_token (&s, &len)) != 0)
+ new_argv[n++] = xstrndup (t, len);
+ }
+
+ /* Set the command to invoke. */
+ new_argv[n++] = line;
+ new_argv[n++] = NULL;
+ }
return new_argv;
}