diff options
Diffstat (limited to 'job.c')
-rw-r--r-- | job.c | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -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; } |