summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2012-03-03 22:56:20 +0000
committerPaul Smith <psmith@gnu.org>2012-03-03 22:56:20 +0000
commit405c89ba1e33e013f7e582e28f969fc3f39b9b2c (patch)
tree55f781c6c18edf75f75ac95f54f9fec2e631996b /job.c
parenta77c5c09100ef56940546b543dd1c515529ca4bb (diff)
downloadgunmake-405c89ba1e33e013f7e582e28f969fc3f39b9b2c.tar.gz
Ensure that .ONESHELL works with .SHELLFLAGS options containing whitespace.
See Savannah bug #35397.
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;
}