[gnu.utils.bug] Fix for make 3.56 use PATH for shell commands

bothner@WSL.DEC.COM (10/20/89)

Make first tries to execve a command. If that fails due
to an ENOEXEC, it tries to use the shell to execute the command.
However, it does not do PATH expansion for the command name
passed to the shell.

A fix is appended. I also removed a signal(SIGTRAP, ...)
in main.c, since it prevent gdb form working.

*** job.c.dist	Thu Sep 21 15:49:50 1989
--- job.c	Thu Oct 19 18:35:13 1989
***************
*** 616,622
    path = allocated_variable_expand_for_file ("$(PATH)", file);
  
    /* Run the command.  */
!   exec_command (argv, envp, path);
  
    /* If exec_command returned, then we should use the shell.  */
    {

--- 616,622 -----
    path = allocated_variable_expand_for_file ("$(PATH)", file);
  
    /* Run the command.  */
!   exec_command (argv, envp, path, file);
  
  }
  
***************
*** 618,641
    /* Run the command.  */
    exec_command (argv, envp, path);
  
-   /* If exec_command returned, then we should use the shell.  */
-   {
-     int argc;
-     char **shell_argv;
- 
-     argc = 0;
-     while (argv[argc] != 0)
-       ++argc;
-     shell_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
-     shell_argv[0] = variable_expand_for_file ("$(SHELL)", file);
-     shell_argv[1 + argc] = 0;
-     while (argc-- > 0)
-       shell_argv[1 + argc] = argv[argc];
-     exec_command (shell_argv, envp, path);
- 
-     /* If that returned, die.  */
-     _exit (127);
-   }
  }
  
  /* Replace the current process with one running the command

--- 618,623 -----
    /* Run the command.  */
    exec_command (argv, envp, path, file);
  
  }
  
  /* Replace the current process with one running the command
***************
*** 643,649
     is searched for in PATH.  This function does not return.  */
  
  void
! exec_command (argv, envp, path)
       char **argv, **envp;
       char *path;
  {

--- 625,631 -----
     is searched for in PATH.  This function does not return.  */
  
  void
! exec_command (argv, envp, path, file)
       char **argv, **envp;
       char *path;
       struct file *file;
***************
*** 646,651
  exec_command (argv, envp, path)
       char **argv, **envp;
       char *path;
  {
    char *program;
  

--- 628,634 -----
  exec_command (argv, envp, path, file)
       char **argv, **envp;
       char *path;
+      struct file *file;
  {
    char *program;
  
***************
*** 723,729
  
    execve (program, argv, envp);
  
!   if (errno != ENOEXEC)
      {
        perror_with_name ("execve: ", program);
        _exit (127);

--- 706,712 -----
  
    execve (program, argv, envp);
  
!   if (file && errno == ENOEXEC)
      {
        int argc;
        char **shell_argv;
***************
*** 725,733
  
    if (errno != ENOEXEC)
      {
!       perror_with_name ("execve: ", program);
!       _exit (127);
!     }
  }
  
  /* Figure out the argument list necessary to run LINE as a command.

--- 708,730 -----
  
    if (file && errno == ENOEXEC)
      {
!       int argc;
!       char **shell_argv;
! 
!       argc = 0;
!       while (argv[argc] != 0)
! 	++argc;
!       shell_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
!       shell_argv[0] = variable_expand_for_file ("$(SHELL)", file);
!       shell_argv[1 + argc] = 0;
!       while (--argc > 0)
! 	shell_argv[1 + argc] = argv[argc];
!       shell_argv[1] = program;
!       exec_command (shell_argv, envp, path, (struct file*)0);
!   }
! 
!   perror_with_name ("execve: ", program);
!   _exit (127);
  }
  
  /* Figure out the argument list necessary to run LINE as a command.
*** main.c.dist	Thu Sep 21 16:15:58 1989
--- main.c	Thu Oct 19 18:36:38 1989
***************
*** 300,307
      (void) signal (SIGINT, SIG_IGN);
    if (signal (SIGILL, fatal_error_signal) == SIG_IGN)
      (void) signal (SIGILL, SIG_IGN);
-   if (signal (SIGTRAP, fatal_error_signal) == SIG_IGN)
-     (void) signal (SIGTRAP, SIG_IGN);
    if (signal (SIGIOT, fatal_error_signal) == SIG_IGN)
      (void) signal (SIGIOT, SIG_IGN);
  #ifdef	SIGEMT

--- 300,305 -----
      (void) signal (SIGINT, SIG_IGN);
    if (signal (SIGILL, fatal_error_signal) == SIG_IGN)
      (void) signal (SIGILL, SIG_IGN);
    if (signal (SIGIOT, fatal_error_signal) == SIG_IGN)
      (void) signal (SIGIOT, SIG_IGN);
  #ifdef	SIGEMT
***************
*** 805,812
  		sprintf (*p, "MAKELEVEL=%u", makelevel);
  		break;
  	      }
! 	  exec_command (argv, environ, allocated_variable_expand ("$(PATH)"));
! 	  pfatal_with_name ("exec_command");
  	  /* NOTREACHED */
  	}
      }

--- 803,810 -----
  		sprintf (*p, "MAKELEVEL=%u", makelevel);
  		break;
  	      }
! 	  exec_command (argv, environ, allocated_variable_expand ("$(PATH)"),
! 			(struct file*)0);
  	  /* NOTREACHED */
  	}
      }