From 405c89ba1e33e013f7e582e28f969fc3f39b9b2c Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 3 Mar 2012 22:56:20 +0000 Subject: Ensure that .ONESHELL works with .SHELLFLAGS options containing whitespace. See Savannah bug #35397. --- job.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'job.c') 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; } -- cgit v1.2.3