[gnu.bash.bug] bash 1.02 - 386/ix

jjc@UUNET.UU.NET (James Clark) (07/10/89)

Here are some patches to make bash 1.02 work on 386/ix (SVR3.2).

The significant problems were:

-- it dumps core on EOF; this happens on a Sun 4/SunOS 4 as well

-- when a child process that catches interrupts gets an interrupt,
   bash also gets an interrupt and does a throw_to_top_level() with
   the result that the child process and bash end up reading 
   simultaneously from the terminal.

There were also a couple of minor glitches in the Makefiles: System V
make doesn't understand `%' in rules, and there's no ranlib.

James Clark
jjc@jclark.uucp

diff -rc bash-1.02/general.h bash/general.h
*** bash-1.02/general.h	Thu Jun 29 13:43:24 1989
--- bash/general.h	Mon Jul 10 07:19:20 1989
***************
*** 39,45 ****
  #endif
  
  /* The output of `signal' is different on different systems.  Yechh. */
! #if defined(SUNOS4) || defined (NeXT)
  #define sighandler void
  #else
  #define sighandler int
--- 39,45 ----
  #endif
  
  /* The output of `signal' is different on different systems.  Yechh. */
! #if defined(SUNOS4) || defined (NeXT) || defined (i386)
  #define sighandler void
  #else
  #define sighandler int

diff -rc bash-1.02/lib/readline.c bash/lib/readline.c
*** bash-1.02/lib/readline.c	Thu Jul  6 13:36:14 1989
--- bash/lib/readline.c	Sun Jul  9 19:22:01 1989
***************
*** 59,65 ****
  
  #include <pwd.h>
  #ifdef SYSV
! struct pwd *getpwuid (), *getpwent ();
  #endif
  
  #define HACK_TERMCAP_MOTION
--- 59,65 ----
  
  #include <pwd.h>
  #ifdef SYSV
! struct passwd *getpwuid (), *getpwent ();
  #endif
  
  #define HACK_TERMCAP_MOTION
diff -rc bash-1.02/lib/readline.h bash/lib/readline.h
*** bash-1.02/lib/readline.h	Thu Jun 29 16:07:03 1989
--- bash/lib/readline.h	Sun Jul  9 19:43:34 1989
***************
*** 138,144 ****
  /* Pointer to the generator function for completion_matches ().
     NULL means to use filename_entry_function (), the default filename
     completer. */
! Function *rl_completion_entry_function;
  
  /* Pointer to alternative function to create matches.
     Function is called with TEXT, START, and END.
--- 138,144 ----
  /* Pointer to the generator function for completion_matches ().
     NULL means to use filename_entry_function (), the default filename
     completer. */
! extern Function *rl_completion_entry_function;
  
  /* Pointer to alternative function to create matches.
     Function is called with TEXT, START, and END.
***************
*** 147,153 ****
     If this function exists and returns NULL then call the value of
     rl_completion_entry_function to try to match, otherwise use the
     array of strings returned. */
! Function *rl_attempted_completion_function;
  
  
  /* **************************************************************** */
--- 147,153 ----
     If this function exists and returns NULL then call the value of
     rl_completion_entry_function to try to match, otherwise use the
     array of strings returned. */
! extern Function *rl_attempted_completion_function;
  
  
  /* **************************************************************** */

diff -rc bash-1.02/nojobs.c bash/nojobs.c
*** bash-1.02/nojobs.c	Fri Jun 23 00:44:18 1989
--- bash/nojobs.c	Mon Jul 10 07:14:30 1989
***************
*** 135,146 ****
  {
    int got_pid, return_val;
    union wait status;
  
    while ((got_pid = wait (&status)) != pid) {
      if (got_pid < 0 && errno != EINTR)
        programming_error ("got errno %d while waiting for %d", errno, pid);
    }
!   
    /* Default return value. */
    return_val = status.w_retcode & 0x7f;
  
--- 135,153 ----
  {
    int got_pid, return_val;
    union wait status;
+   SigHandler *old_int, *old_quit;
  
+   old_int = signal (SIGINT, SIG_IGN);
+   old_quit = signal (SIGQUIT, SIG_IGN);
+ 
    while ((got_pid = wait (&status)) != pid) {
      if (got_pid < 0 && errno != EINTR)
        programming_error ("got errno %d while waiting for %d", errno, pid);
    }
! 
!   signal (SIGINT, old_int);
!   signal (SIGQUIT, old_quit);
! 
    /* Default return value. */
    return_val = status.w_retcode & 0x7f;
  
diff -rc bash-1.02/parse.y bash/parse.y
*** bash-1.02/parse.y	Sat Jul  1 21:42:28 1989
--- bash/parse.y	Sun Jul  9 19:51:26 1989
***************
*** 430,435 ****
--- 430,442 ----
  	current_readline_line = readline (current_readline_prompt);
  
        current_readline_line_index = 0;
+ 
+       if (current_readline_line == (char *)EOF) 
+ 	{
+ 	  current_readline_line = NULL;
+ 	  return EOF;
+ 	}
+ 
        current_readline_line =
  	(char *)xrealloc (current_readline_line,
  			  2 + strlen (current_readline_line));

diff -rc bash-1.02/shell.c bash/shell.c
*** bash-1.02/shell.c	Sat Jul  1 14:33:04 1989
--- bash/shell.c	Mon Jul 10 04:11:03 1989
***************
*** 301,307 ****
    else
      {
        interactive = 0;
! #ifndef JOB_CONTROL
        job_control = 0;
  #endif
      }
--- 301,307 ----
    else
      {
        interactive = 0;
! #ifndef NOJOBS
        job_control = 0;
  #endif
      }
diff -rc bash-1.02/variables.c bash/variables.c
*** bash-1.02/variables.c	Tue Jun 27 16:40:42 1989
--- bash/variables.c	Sun Jul  9 19:19:25 1989
***************
*** 27,33 ****
  #include "version.h"
  
  #ifdef SYSV
! struct pwd *getpwuid (), *getpwent ();
  #endif
  
  /* The list of shell variables that the user has created, or that came from
--- 27,33 ----
  #include "version.h"
  
  #ifdef SYSV
! struct passwd *getpwuid (), *getpwent ();
  #endif
  
  /* The list of shell variables that the user has created, or that came from