Index: job.c
===================================================================
RCS file: /sources/make/make/job.c,v
retrieving revision 1.211
diff -t -r1.211 job.c
2316c2316,2370
< 
---
> 
> char * escape_string(char * ap, char * string, char ** restp, const char sh_chars[])
> {
>   char * p;
>   for (p = string; *p != '\0'; ++p)
>   {
>     if (restp != NULL && *p == '\n')
>       {
>         *restp = p;
>         break;
>       }
>     else if (*p == '\\' && p[1] == '\n')
>       {
>         /* POSIX says we keep the backslash-newline.  If we don't have a
>            POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
>            and remove the backslash/newline.  */
> #if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
> # define PRESERVE_BSNL  unixy_shell
> #else
> # define PRESERVE_BSNL  1
> #endif
>         if (PRESERVE_BSNL)
>           {
>             *(ap++) = '\\';
>             /* Only non-batch execution needs another backslash,
>                because it will be passed through a recursive
>                invocation of this function.  */
>             if (!batch_mode_shell)
>               *(ap++) = '\\';
>             *(ap++) = '\n';
>           }
>         ++p;
>         continue;
>       }
> 
>     /* DOS shells don't know about backslash-escaping.  */
>     if (unixy_shell && !batch_mode_shell &&
>         (*p == '\\' || *p == '\'' || *p == '"'
>          || isspace ((unsigned char)*p)
>          || strchr (sh_chars, *p) != 0))
>       *ap++ = '\\';
> #ifdef __MSDOS__
>     else if (unixy_shell && strneq (p, "...", 3))
>       {
>         /* The case of `...' wildcard again.  */
>         strcpy (ap, "\\.\\.\\");
>         ap += 5;
>         p  += 2;
>       }
> #endif
>     *ap++ = *p;
>   }
>   return ap;
> }
> 
2920c2974
<     new_line = alloca (shell_len + 1 + sflags_len + 1
---
>     new_line = alloca ((shell_len*2) + 1 + sflags_len + 1
2923,2924c2977
<     memcpy (ap, shell, shell_len);
<     ap += shell_len;
---
>     ap = escape_string(ap, shell, 0, sh_chars);
2930,2978c2983,2984
<     for (p = line; *p != '\0'; ++p)
<       {
<         if (restp != NULL && *p == '\n')
<           {
<             *restp = p;
<             break;
<           }
<         else if (*p == '\\' && p[1] == '\n')
<           {
<             /* POSIX says we keep the backslash-newline.  If we don't have a
<                POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
<                and remove the backslash/newline.  */
< #if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
< # define PRESERVE_BSNL  unixy_shell
< #else
< # define PRESERVE_BSNL  1
< #endif
<             if (PRESERVE_BSNL)
<               {
<                 *(ap++) = '\\';
<                 /* Only non-batch execution needs another backslash,
<                    because it will be passed through a recursive
<                    invocation of this function.  */
<                 if (!batch_mode_shell)
<                   *(ap++) = '\\';
<                 *(ap++) = '\n';
<               }
<             ++p;
<             continue;
<           }
< 
<         /* DOS shells don't know about backslash-escaping.  */
<         if (unixy_shell && !batch_mode_shell &&
<             (*p == '\\' || *p == '\'' || *p == '"'
<              || isspace ((unsigned char)*p)
<              || strchr (sh_chars, *p) != 0))
<           *ap++ = '\\';
< #ifdef __MSDOS__
<         else if (unixy_shell && strneq (p, "...", 3))
<           {
<             /* The case of `...' wildcard again.  */
<             strcpy (ap, "\\.\\.\\");
<             ap += 5;
<             p  += 2;
<           }
< #endif
<         *ap++ = *p;
<       }
<     if (ap == new_line + shell_len + sflags_len + 2)
---
>     ap = escape_string(ap, line, restp, sh_chars);
>     if (ap == command_ptr)
2993c2999
<     } else if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
---
>     } else if ((no_default_sh_exe || batch_mode_shell) && batch_filename_p) {
3001c3007
<       *batch_filename_ptr = create_batch_file (fbuf, unixy_shell, &temp_fd);
---
>       *batch_filename_p = create_batch_file (fbuf, unixy_shell, &temp_fd);
3004c3010
<                     *batch_filename_ptr));
---
>                     *batch_filename_p));
3022c3028
<         new_argv[1] = *batch_filename_ptr; /* only argv[0] gets freed later */
---
>         new_argv[1] = *batch_filename_p; /* only argv[0] gets freed later */
3024c3030
<         new_argv[0] = xstrdup (*batch_filename_ptr);
---
>         new_argv[0] = xstrdup (*batch_filename_p);
