[alt.sources] bash-1.05 with POSIX job control on ISC 2.2.1

src@scuzzy.in-berlin.de (Heiko Blume) (01/17/91)

well, if you have Interactive 2.2.1 you can now have a bourne
shell lookalike with job control. for that you have to get
the bash-1.05.tar.Z and bash-1.05-patches.tar.Z from prep.ai.mit.edu
or your favorite archive site and apply those patches. then
apply the patch below with "patch -p1 < ThisArticle".
then type make.

note, however, that i use gcc-1.38 (*WITHOUT* -traditional) and
bison-1.12 here on ISC 2.2.1. if you don't have 2.2.1, go get it.
if you don't use gcc/bison you'll have to fiddle with cpp-Makefile
and Makefile. since i didn't even try it with cc, you're on your
own with that.

you should also note that the builtin pwd doesn't work correctly,
for reasons that are totally beyond me until now. i simply
alias pwd=/bin/pwd, no problems otherwise. (any hints appreciated!)

i'm sure i made some errors somewhere and some kludges too,
but what the hey - i already look forward to the flames ...

final note: don't forget the 'stty swtch ^z' in your .login or .bashrc !


*** bash-1.05/ChangeLog	Wed Jan 16 22:53:35 1991
--- bash-1.05.new/ChangeLog	Wed Jan 16 23:28:12 1991
***************
*** 1,3 ****
--- 1,18 ----
+ 
+ Wed Jan 16 22:58:01 MET 1991 Heiko Blume (src at scuzzy.in-berlin.de)
+ 
+ 	* jobs.c, builtins.c, config.h, cpp-Makefile, execute_cmd.c,
+ 	general.h, glob.c, jobs.c, readline.c, shell.c, shell.h,
+ 	subst.c, test.c variables.c: general changes for the posix
+ 	environment on Interactive UNIX Release 2.2.1 with gcc-1.38,
+ 	especially to get job control working in the first place,
+ 	i.e. signal () -> sigset (), sigpause () -> sigsuspend (),
+ 	sigblock () , sigsetmask () -> sigprocmask (), setjmp () ->
+ 	sigsetjmp (), longjmp -> siglongjmp, wait3 () -> waitpid (),
+ 	use S_IS* macros for file type testing. these changes ONLY
+ 	take effect when both "POSIX" and "_POSIX_SOURCE" are defined.
+ 
+ 
  Sun Mar 11 04:28:30 1990  Brian Fox  (bfox at gnuwest.fsf.org)
  
  	* parse.y: handle_eof_unit () now alls reset_parser () before
*** bash-1.05/Makefile	Wed Jan 16 22:53:36 1991
--- bash-1.05.new/Makefile	Wed Jan 16 23:29:37 1991
***************
*** 13,18 ****
--- 13,19 ----
  DESTDIR = /usr/gnu/bin
  MAKE = make
  #CPP_DEFINES = -DHAVE_GCC -DHAVE_FIXED_INCLUDES -DHAVE_BISON
+ CPP_DEFINES = -DHAVE_GCC -DHAVE_BISON 
  
  CPP = /lib/cpp $(CPPFLAGS)
  #CPP = $(CC) -E
***************
*** 25,31 ****
  
  bash-Makefile: cpp-Makefile Makefile machines.h makeargs.sh
  	cp cpp-Makefile tmp-Makefile.c
! 	@echo $(CPP) $(CPP_ARGS) tmp-Makefile.c \| cat -s >bash-Makefile
  	@$(CPP) $(CPP_ARGS) tmp-Makefile.c | cat -s >bash-Makefile
  	rm -f tmp-Makefile.c
  
--- 26,32 ----
  
  bash-Makefile: cpp-Makefile Makefile machines.h makeargs.sh
  	cp cpp-Makefile tmp-Makefile.c
! 	@echo $(CPP) $(CPPFLAGS) $(CPP_ARGS) tmp-Makefile.c \| cat -s \>bash-Makefile
  	@$(CPP) $(CPP_ARGS) tmp-Makefile.c | cat -s >bash-Makefile
  	rm -f tmp-Makefile.c
  
*** bash-1.05/builtins.c	Wed Jan 16 22:53:37 1991
--- bash-1.05.new/builtins.c	Mon Jan 14 18:58:34 1991
***************
*** 217,223 ****
  	the last N lines.  Argument `-w' means write out the current\n\
  	history file.  `-r' means to read it instead.  If FILENAME is\n\
  	given, then use that file, else if $HISTFILE has a value, use\n\
! 	that, else use ~/.bash_history.  Argument -s oerforms history\n\
  	substitution on the following args" },
  
  #ifdef JOB_CONTROL
--- 217,223 ----
  	the last N lines.  Argument `-w' means write out the current\n\
  	history file.  `-r' means to read it instead.  If FILENAME is\n\
  	given, then use that file, else if $HISTFILE has a value, use\n\
! 	that, else use ~/.bash_history.  Argument -s performs history\n\
  	substitution on the following args" },
  
  #ifdef JOB_CONTROL
***************
*** 855,861 ****
--- 855,865 ----
        if (sscanf (list->word->word, "%d", &count) != 1)
  	{
  	  builtin_error ("bad non-numeric arg `%s'", list->word->word);
+ #ifndef _POSIX_SOURCE
  	  longjmp (top_level, DISCARD);
+ #else
+ 	  siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  	}
        no_args (list->next);
      }
***************
*** 1329,1335 ****
--- 1333,1343 ----
  	       going through the command parser. */
  	    last_shell_builtin = exit_builtin;
  
+ #ifndef _POSIX_SOURCE
  	    longjmp (top_level, DISCARD);
+ #else
+ 	    siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  	  }
      }
  #endif
***************
*** 1345,1351 ****
--- 1353,1363 ----
      maybe_execute_file ("~/.bash_logout");
  
    /* Exit the program. */
+ #ifndef _POSIX_SOURCE
    longjmp (top_level, EXITPROG);
+ #else
+   siglongjmp (top_level, EXITPROG);
+ #endif /* _POSIX_SOURCE */
  }
  
  /* For each variable name in LIST, make that variable appear in the
***************
*** 1699,1733 ****
  
  	return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
        }
!     }
! 
!   if (strcmp (list->word->word, "-s") == 0)
!     {
!       extern int history_expand ();
!       char *expanded;
!       int rval;
! 
!       list = list->next;
! 
!       while (list)
  	{
! 	  rval = history_expand (list->word->word, &expanded);
! 	  printf ("%s", expanded);
! 	  fflush (stdout);
! 
! 	  if (rval == -1)
! 	    return (EXECUTION_FAILURE);
! 
! 	  free (expanded);
! 
  	  list = list->next;
  	}
      }
!   
!   limit = get_numeric_arg (list);
!   if (limit < 0)
!     limit = -limit;
!   
    if (!limited)
      i = 0;
    else
--- 1711,1745 ----
  
  	return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
        }
!       
!       if (strcmp (list->word->word, "-s") == 0)
  	{
! 	  extern int history_expand ();
! 	  char *expanded;
! 	  int rval;
! 	  
  	  list = list->next;
+ 	  
+ 	  while (list)
+ 	    {
+ 	      rval = history_expand (list->word->word, &expanded);
+ 	      printf ("%s", expanded);
+ 	      fflush (stdout);
+ 	      
+ 	      if (rval == -1)
+ 		return (EXECUTION_FAILURE);
+ 	      
+ 	      free (expanded);
+ 	      
+ 	      list = list->next;
+ 	    }
  	}
+       
+       limit = get_numeric_arg (list);
+       if (limit < 0)
+ 	limit = -limit;
      }
!     
    if (!limited)
      i = 0;
    else
***************
*** 1753,1764 ****
       WORD_LIST *list;
  {
    char *get_working_directory (), *getwd (), *directory;
- 
    no_args (list);
  
    if (verbatim_pwd)
      {
!       char *buffer = (char *)xmalloc (MAXPATHLEN);
        directory = getwd (buffer);
  
        if (!directory)
--- 1765,1775 ----
       WORD_LIST *list;
  {
    char *get_working_directory (), *getwd (), *directory;
    no_args (list);
  
    if (verbatim_pwd)
      {
!       char *buffer = (char *) xmalloc (MAXPATHLEN);
        directory = getwd (buffer);
  
        if (!directory)
***************
*** 1776,1782 ****
      {
        printf ("%s\n", directory);
        fflush (stdout);
!       free (directory);
        return (EXECUTION_SUCCESS);
      }
    else
--- 1787,1793 ----
      {
        printf ("%s\n", directory);
        fflush (stdout);
!       free (directory); 
        return (EXECUTION_SUCCESS);
      }
    else
***************
*** 1916,1922 ****
--- 1927,1937 ----
  {
    extern int last_command_exit_value;
    extern int return_catch_flag, return_catch_value;
+ #ifndef _POSIX_SOURCE
    extern jmp_buf return_catch;
+ #else
+   extern sigjmp_buf return_catch;
+ #endif /* _POSIX_SOURCE */
  
    return_catch_value = get_numeric_arg (list);
  
***************
*** 1924,1934 ****
--- 1939,1957 ----
      return_catch_value = last_command_exit_value;
  
    if (return_catch_flag)
+ #ifndef _POSIX_SOURCE
      longjmp (return_catch, 1);
+ #else
+     siglongjmp (return_catch, 1);
+ #endif /* _POSIX_SOURCE */
    else
      {
        builtin_error ("Can only `return' from a function");
+ #ifndef _POSIX_SOURCE
        longjmp (top_level, DISCARD);
+ #else
+       siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
      }
  }
  
***************
*** 2113,2119 ****
--- 2136,2146 ----
    if (list)
      {
        builtin_error ("extra arguments");
+ #ifndef _POSIX_SOURCE
        longjmp (top_level, DISCARD);
+ #else
+       siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
      }
  }
  
***************
*** 3306,3325 ****
        else if (job_control)
  	/* Must be a job spec.  Check it out. */
  	{
  	  int oldmask = sigblock (sigmask (SIGCHLD));
! 	  int job = get_job_spec (list);
  
  	  if (job < 0 || job >= job_slots || !jobs[job])
  	    {
  	      if (job != DUP_JOB)
  		builtin_error ("No such job %s", list->word->word);
  	      sigsetmask (oldmask);
  	      return (EXECUTION_FAILURE);
  	    }
  
  	  /* Job spec used.  Wait for the last pid in the pipeline. */
  
! 	  sigsetmask (oldmask);
  
  	  status = wait_for_job (job);
  	}
--- 3333,3368 ----
        else if (job_control)
  	/* Must be a job spec.  Check it out. */
  	{
+ 	  int job;
+ #ifndef _POSIX_SOURCE
  	  int oldmask = sigblock (sigmask (SIGCHLD));
! #else
! 	  sigset_t oldmask,newmask;
! 	  newmask=sigmask(SIGCHLD);
! 	  sigprocmask(SIG_BLOCK,&newmask,&oldmask);
! #endif
! 
! 	  job = get_job_spec (list);
  
  	  if (job < 0 || job >= job_slots || !jobs[job])
  	    {
  	      if (job != DUP_JOB)
  		builtin_error ("No such job %s", list->word->word);
+ #ifndef _POSIX_SOURCE
  	      sigsetmask (oldmask);
+ #else
+ 		  sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  	      return (EXECUTION_FAILURE);
  	    }
  
  	  /* Job spec used.  Wait for the last pid in the pipeline. */
  
! #ifndef _POSIX_SOURCE
! 	      sigsetmask (oldmask);
! #else
! 		  sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  
  	  status = wait_for_job (job);
  	}
***************
*** 3427,3439 ****
--- 3470,3490 ----
    if (login_shell)
      {
        builtin_error ("Can't suspend a login shell");
+ #ifndef _POSIX_SOURCE
        longjmp (top_level, DISCARD);
+ #else
+       siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
      }
  
  do_suspend:
    old_cont = (SigHandler *)signal (SIGCONT, suspend_continue);
    old_tstp = (SigHandler *)signal (SIGTSTP, SIG_DFL);
+ #ifndef _POSIX_SOURCE
    killpg (shell_pgrp, SIGTSTP);
+ #else
+   kill ( -(shell_pgrp), SIGTSTP);
+ #endif
    return (EXECUTION_SUCCESS);
  }
  
***************
*** 3634,3647 ****
  	}
        else if (job_control)     /* can't kill jobs if not using job control */
  	{			/* Must be a job spec.  Check it out. */
! 	  int oldmask = sigblock (sigmask (SIGCHLD));
! 	  int job = get_job_spec (list);
  
  	  if (job < 0 || job >= job_slots || !jobs[job])
  	    {
  	      if (job != DUP_JOB)
  		builtin_error ("No such job %s", list->word->word);
! 	      sigsetmask (oldmask);
  	      CONTINUE_OR_FAIL;
  	    }
  
--- 3685,3709 ----
  	}
        else if (job_control)     /* can't kill jobs if not using job control */
  	{			/* Must be a job spec.  Check it out. */
! 	  int job;
! #ifndef _POSIX_SOURCE
! 	  sigset_t oldmask = sigblock (sigmask (SIGCHLD));
! #else
!  	  sigset_t oldmask,newmask;
! 	  newmask=sigmask(SIGCHLD);
! 	  sigprocmask(SIG_BLOCK,&newmask,&oldmask);
! #endif
! 	  job = get_job_spec (list);
  
  	  if (job < 0 || job >= job_slots || !jobs[job])
  	    {
  	      if (job != DUP_JOB)
  		builtin_error ("No such job %s", list->word->word);
! #ifndef _POSIX_SOURCE
! 	    sigsetmask (oldmask);
! #else
! 		sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  	      CONTINUE_OR_FAIL;
  	    }
  
***************
*** 3654,3660 ****
  	  else
  	    pid = jobs[job]->pipe->pid;
  
! 	  sigsetmask (oldmask);
  
  	  if (kill_pid (pid, signal, 1) < 0)
  	    {
--- 3716,3726 ----
  	  else
  	    pid = jobs[job]->pipe->pid;
  
! #ifndef _POSIX_SOURCE
!       sigsetmask (oldmask);
! #else
! 	  sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  
  	  if (kill_pid (pid, signal, 1) < 0)
  	    {
***************
*** 3686,3692 ****
--- 3752,3762 ----
  {
    int job = NO_JOB;
    JOB_STATE job_state;
+ #ifndef _POSIX_SOURCE
    int oldmask;
+ #else
+   sigset_t nullmask,oldmask,newmask;
+ #endif
    PROCESS *process, *pipeline;
  
    if (!job_control)
***************
*** 3694,3705 ****
--- 3764,3787 ----
  
    job = get_job_spec (list);
  
+ #ifndef _POSIX_SOURCE
    oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   nullmask = (sigset_t) 0;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
    job_state = JOBSTATE(job);
  
+ #ifndef _POSIX_SOURCE
    killpg (jobs[job]->pgrp, SIGSTOP);
    while (jobs[job] && JOBSTATE (job) == JRUNNING)
      sigpause (0);
+ #else
+   kill( -(jobs[job]->pgrp), SIGSTOP);
+   while (jobs[job] && JOBSTATE (job) == JRUNNING)
+ 	sigsuspend(&nullmask);
+ #endif /* _POSIX_SOURCE */
  
    /* Make the process group of the pipeline the same as init's.  */
    process = pipeline = jobs[job]->pipe;
***************
*** 3725,3731 ****
--- 3807,3818 ----
    /* Remove the job from the job list. */
    delete_job (job);
  
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
+ 
  }
  #endif /* DETACH */
  #endif  /* JOB_CONTROL */
*** bash-1.05/config.h	Sun Feb 25 15:19:30 1990
--- bash-1.05.new/config.h	Wed Jan 16 15:18:48 1991
***************
*** 32,42 ****
  
  /* Define JOB_CONTROL if your operating system supports
     BSD-like job control. */
! #define JOB_CONTROL
  
  /* Note that System V machines don't support job control. */
  #if defined (SYSV)
  #undef JOB_CONTROL
  #endif /* SYSV */
  
  /* Define ALIAS if you want the alias features. */
--- 32,50 ----
  
  /* Define JOB_CONTROL if your operating system supports
     BSD-like job control. */
! #if defined (POSIX)
! #define POSIX_JC				/* more weird ISC define shit */
! #define POSIX_SUPPORT
! #define JOB_CONTROL				/* will we succeed ?! */
! #define signal sigset			/* signal(2) is NOT reliable */
! #endif
  
  /* Note that System V machines don't support job control. */
+ /* Note that some POSIXish Sys V's do support it anyway */
  #if defined (SYSV)
+ #ifndef _POSIX_SOURCE
  #undef JOB_CONTROL
+ #endif /* _POSIX_SOURCE */
  #endif /* SYSV */
  
  /* Define ALIAS if you want the alias features. */
*** bash-1.05/cpp-Makefile	Wed Jan 16 22:53:38 1991
--- bash-1.05.new/cpp-Makefile	Wed Jan 16 15:46:15 1991
***************
*** 62,68 ****
  /* This is gauranteed to work, even if you have the fixed includes!
     (Unless, of course, you have the fixed include files installed in
     /usr/include.  Then it will break. ) */
! CC = gcc -traditional -I/usr/include
  #else
  CC = gcc
  #endif /* !HAVE_FIXED_INCLUDES */
--- 62,69 ----
  /* This is gauranteed to work, even if you have the fixed includes!
     (Unless, of course, you have the fixed include files installed in
     /usr/include.  Then it will break. ) */
! /* CC = gcc -traditional -I/usr/include */
! CC = gcc -DPOSIX -D_POSIX_SOURCE
  #else
  CC = gcc
  #endif /* !HAVE_FIXED_INCLUDES */
***************
*** 111,117 ****
--- 112,122 ----
  #endif /* SYSDEP_CFLAGS */
  
  SYSTEM_FLAGS = $(LINEBUF) $(VPRINTF) -D$(MACHINE) -D$(OS) $(SYSDEP)
+ #if defined (HAVE_GCC)
+ DEBUG_FLAGS = $(PROFILE_FLAGS) -g -O
+ #else
  DEBUG_FLAGS = $(PROFILE_FLAGS) -g
+ #endif
  LDFLAGS	= $(DEBUG_FLAGS)
  CFLAGS	= $(DEBUG_FLAGS) $(SYSTEM_FLAGS)
  CPPFLAGS= -I$(LIBSRC)
***************
*** 185,190 ****
--- 190,196 ----
  READLINE= ./readline/libreadline.a
  
  /**/# Locally required libraries.
+ #define REQUIRED_LIBRARIES -lcposix
  #if defined (REQUIRED_LIBRARIES)
  LOCAL_LIBS = REQUIRED_LIBRARIES
  #endif
***************
*** 264,270 ****
  
  $(PROGRAM):	.build $(OBJECTS) $(LIBDEP) bash-Makefile
  	$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJECTS) \
! 		$(LIBRARIES) $(LOCAL_LIBS) $(TERMLIB)
  	$(RM) -f .make
  
  .build:		.make newversion.aux
--- 270,276 ----
  
  $(PROGRAM):	.build $(OBJECTS) $(LIBDEP) bash-Makefile
  	$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJECTS) \
! 		$(LIBRARIES) $(LOCAL_LIBS) 
  	$(RM) -f .make
  
  .build:		.make newversion.aux
***************
*** 311,320 ****
  		touch keymaps.c
  
  #if defined (USE_GNU_MALLOC)
  $(MALLOC):	$(ALLOC_FILES)
  		$(CC) -I$(ALLOC_DIR) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c
- #if !defined (__GNUC__)
  		@-mv `basename $*`.o $(MALLOC) 2>/dev/null
  #endif
  #endif /* USE_GNU_MALLOC */
  
--- 317,329 ----
  		touch keymaps.c
  
  #if defined (USE_GNU_MALLOC)
+ #if !defined (__GNUC__)
  $(MALLOC):	$(ALLOC_FILES)
  		$(CC) -I$(ALLOC_DIR) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c
  		@-mv `basename $*`.o $(MALLOC) 2>/dev/null
+ #else /* GCC */
+ $(MALLOC):	$(ALLOC_FILES)
+ 		$(CC) -I$(ALLOC_DIR) $(CFLAGS) -o $(MALLOC) $(MALLOC_FLAGS) -c $*.c
  #endif
  #endif /* USE_GNU_MALLOC */
  
*** bash-1.05/execute_cmd.c	Wed Jan 16 22:53:38 1991
--- bash-1.05.new/execute_cmd.c	Fri Jan  4 15:42:09 1991
***************
*** 327,333 ****
--- 327,337 ----
  	default:
  	  programming_error ("Bad connector `%d'!",
  			     command->value.Connection->connector);
+ #ifndef _POSIX_SOURCE
  	  longjmp (top_level, DISCARD);
+ #else
+ 	  siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  	  break;
  	}
        break;
***************
*** 577,583 ****
--- 581,591 ----
  /* For catching RETURN in a function. */
  int return_catch_flag = 0;
  int return_catch_value;
+ #ifndef _POSIX_SOURCE
  jmp_buf return_catch;
+ #else
+ sigjmp_buf return_catch;
+ #endif /* _POSIX_SOURCE */
  
  /* The meaty part of all the executions.  We have to start
     hacking the real execution of commands here.  Fork a process,
***************
*** 764,770 ****
--- 772,782 ----
   		    {
   		      int return_val;
   		      extern int dispose_command (), pop_context ();
+ #ifndef _POSIX_SOURCE
  		      jmp_buf old_return_catch;
+ #else
+ 		      sigjmp_buf old_return_catch;
+ #endif /* _POSIX_SOURCE */
   		      COMMAND *tc;
  		      
  		      tc = (COMMAND *)copy_command (function_cell (var));
***************
*** 780,788 ****
--- 792,806 ----
  		      remember_args (words->next, 1);
  
   		      return_catch_flag++;
+ #ifndef _POSIX_SOURCE
  		      bcopy ((char *)return_catch, (char *)old_return_catch,
  			     sizeof (jmp_buf));
   		      return_val =  setjmp (return_catch);
+ #else
+ 		      bcopy ((char *)return_catch, (char *)old_return_catch,
+ 			     sizeof (sigjmp_buf));
+ 			  return_val =  sigsetjmp (return_catch, 1);
+ #endif /* _POSIX_SOURCE */
   
   		      if (return_val)
  			result = return_catch_value;
***************
*** 791,798 ****
--- 809,821 ----
  
   		      run_unwind_frame ("function_calling");
   		      return_catch_flag--;
+ #ifndef _POSIX_SOURCE
  		      bcopy ((char *)old_return_catch, (char *)return_catch,
  			     sizeof (jmp_buf));
+ #else
+ 		      bcopy ((char *)old_return_catch, (char *)return_catch,
+ 			     sizeof (sigjmp_buf));
+ #endif /* _POSIX_SOURCE */
   		    }
  		  redirection_undo_list = saved_undo_list;
   		}
***************
*** 880,886 ****
--- 903,913 ----
  		  if (errno != ENOEXEC)
  		    {
  		      if ((stat (command, &finfo) == 0) &&
+ #ifndef _POSIX_SOURCE
  			  ((finfo.st_mode & S_IFMT) == S_IFDIR))
+ #else
+ 			  (S_ISDIR(finfo.st_mode)))
+ #endif
  			report_error ("%s: is a directory", args[0]);
  		      else
  			file_error (command);
***************
*** 984,990 ****
--- 1011,1021 ----
  			  /* Oh, no!  We couldn't even exec this! */
  
  			  if ((stat (shell_name, &finfo) == 0) &&
+ #ifndef _POSIX_SOURCE
  			      ((finfo.st_mode & S_IFMT) == S_IFDIR))
+ #else
+ 				  (S_ISDIR(finfo.st_mode)))
+ #endif
  			    report_error ("%s: is a directory", args[0]);
  			  else
  			    file_error (shell_name);
***************
*** 1360,1366 ****
--- 1391,1401 ----
    /* If the file doesn't exist, or is a directory, then we are
       not interested. */
    file_exists_p = !stat (file, &finfo);
+ #ifndef _POSIX_SOURCE
    if (!file_exists_p || (finfo.st_mode & S_IFDIR))
+ #else
+   if (!file_exists_p || (S_ISDIR(finfo.st_mode)))
+ #endif
      return (0);
  
    /* By definition, the only other criteria is that the file has
*** bash-1.05/general.h	Thu Jan 18 04:39:00 1990
--- bash-1.05.new/general.h	Fri Jan  4 15:42:09 1991
***************
*** 39,45 ****
  #endif
  
  /* The output of `signal' is different on different systems.  Yechh. */
! #if defined(SunOS4) || defined (NeXT) || defined (Ultrix)
  #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 (Ultrix) || defined (_POSIX_SOURCE)
  #define sighandler void
  #else
  #define sighandler int
*** bash-1.05/glob.c	Wed Jan 16 22:53:39 1991
--- bash-1.05.new/glob.c	Fri Jan  4 15:42:09 1991
***************
*** 48,54 ****
--- 48,56 ----
  #include <string.h>
  #else
  #if defined (SYSV)
+ #ifndef _POSIX_SOURCE
  #include <memory.h>
+ #endif
  #include <string.h>
  #define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
  #define rindex	strrchr
*** bash-1.05/jobs.c	Wed Jan 16 22:53:40 1991
--- bash-1.05.new/jobs.c	Tue Jan 15 23:42:41 1991
***************
*** 33,39 ****
--- 33,43 ----
  #include <sys/types.h>
  
  #include <sys/time.h>
+ #ifndef _POSIX_SOURCE
  #include <sys/resource.h>
+ #else
+ #include <sys/unistd.h>
+ #endif /* _POSIX_SOURCE */
  #include <sys/file.h>
  
  #include <fcntl.h>
***************
*** 140,147 ****
  int already_making_children = 0;
  
  /* These are definitions to map POSIX 1003.1 functions onto existing BSD
!    library functions and system calls. */
  
  #define setpgid(pid, pgrp)	setpgrp (pid, pgrp)
  #define tcsetpgrp(fd, pgrp)	ioctl ((fd), TIOCSPGRP, &(pgrp))
  
--- 144,153 ----
  int already_making_children = 0;
  
  /* These are definitions to map POSIX 1003.1 functions onto existing BSD
!    library functions and system calls. 
!    src@scuzzy.in-berlin.de: if we *are* posix we don't want these of course */
  
+ #ifndef _POSIX_SOURCE
  #define setpgid(pid, pgrp)	setpgrp (pid, pgrp)
  #define tcsetpgrp(fd, pgrp)	ioctl ((fd), TIOCSPGRP, &(pgrp))
  
***************
*** 156,162 ****
    return (pgrp);
  }
  
! /* END of POISX 1003.1 definitions. */
  
  making_children ()
  {
--- 162,170 ----
    return (pgrp);
  }
  
! #endif /* _POSIX_SOURCE */
! 
! /* END of POSIX 1003.1 definitions. */
  
  making_children ()
  {
***************
*** 193,203 ****
--- 201,220 ----
       COMMAND *deferred;
  {
    register int i, j;
+ #ifndef _POSIX_SOURCE
    int oldmask;
+ #else
+   sigset_t oldmask,newmask;
+ #endif
    JOB *newjob = (JOB *)NULL;
    char *get_string_value ();
  
+ #ifndef _POSIX_SOURCE
    oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    cleanup_dead_jobs ();
  
***************
*** 318,324 ****
--- 335,345 ----
      }
  
    stop_making_children ();
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
    return (current_job);
  }
  
***************
*** 325,338 ****
  /* Delete all DEAD jobs that the user had received notification about. */
  cleanup_dead_jobs ()
  {
-   int oldmask = sigblock (sigmask (SIGCHLD));
    register int i;
  
    for (i = 0; i < job_slots; i++)
      if (jobs[i] && JOBSTATE (i) == JDEAD && jobs[i]->notified)
        delete_job (i);
  
    sigsetmask (oldmask);
  }
  
  /* Delete the job at INDEX from the job list. */
--- 346,369 ----
  /* Delete all DEAD jobs that the user had received notification about. */
  cleanup_dead_jobs ()
  {
    register int i;
+ #ifndef _POSIX_SOURCE
+   int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    for (i = 0; i < job_slots; i++)
      if (jobs[i] && JOBSTATE (i) == JDEAD && jobs[i]->notified)
        delete_job (i);
  
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  }
  
  /* Delete the job at INDEX from the job list. */
***************
*** 489,495 ****
--- 520,532 ----
       int pid;
  {
    int job;
+ #ifndef _POSIX_SOURCE
    int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    job = find_job (pid);
  
***************
*** 498,504 ****
--- 535,545 ----
    else
      programming_error ("describe_pid: No such pid (%d)!\n", pid);
  
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  }
  
  
***************
*** 518,528 ****
--- 559,579 ----
       FILE *stream;
  {
    register PROCESS *p;
+ #ifndef _POSIX_SOURCE
    int first, oldmask;
+ #else
+   int first;
+   sigset_t oldmask,newmask;
+ #endif
    union wait first_job_cond;
    int name_padding;
  
+ #ifndef _POSIX_SOURCE
    oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    fprintf (stream, "[%d]%c ", index + 1,
  	   (index == current_job) ? '+':
***************
*** 622,628 ****
--- 673,683 ----
        p = p->next;
      } while (p != jobs[index]->pipe);
    fflush (stream);
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  }
  
  list_one_job (job, format, ignore, index)
***************
*** 651,659 ****
       char *command;
       int async_p;
  {
!   int pid, oldmask;
    
    oldmask = sigblock (sigmask (SIGINT) | sigmask (SIGCHLD));
  
    making_children ();
  
--- 706,721 ----
       char *command;
       int async_p;
  {
!   int pid;
! #ifndef _POSIX_SOURCE
!   int oldmask;
    
    oldmask = sigblock (sigmask (SIGINT) | sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGINT) | sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    making_children ();
  
***************
*** 665,671 ****
      {
        extern sighandler throw_to_top_level ();
  
!       sigsetmask (oldmask);
        report_error ("Memory exhausted or process overflow!");
        throw_to_top_level ();
      }
--- 727,737 ----
      {
        extern sighandler throw_to_top_level ();
  
! #ifndef _POSIX_SOURCE
!   sigsetmask (oldmask);
! #else
!   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
        report_error ("Memory exhausted or process overflow!");
        throw_to_top_level ();
      }
***************
*** 708,717 ****
  	      signal (SIGTTIN, SIG_DFL);
  	    }
  	
  	  if (!async_p)
  	    give_terminal_to (pipeline_pgrp);
- 
  	  setpgrp (0, pipeline_pgrp);
  	}
        else			/* Without job control... */
  	{
--- 774,789 ----
  	      signal (SIGTTIN, SIG_DFL);
  	    }
  	
+ 
+ #ifndef _POSIX_SOURCE
  	  if (!async_p)
  	    give_terminal_to (pipeline_pgrp);
  	  setpgrp (0, pipeline_pgrp);
+ #else
+ 	  setpgid (0, pipeline_pgrp);
+ 	  if (!async_p)
+ 	    give_terminal_to (pipeline_pgrp);
+ #endif /* _POSIX_SOURCE */
  	}
        else			/* Without job control... */
  	{
***************
*** 763,769 ****
--- 835,845 ----
  
        last_made_pid = pid;
      }
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
    return (pid);
  }
  
***************
*** 819,832 ****
  lastproc (job)
       int job;
  {
-   int oldmask = sigblock (sigmask (SIGCHLD));
    register PROCESS *p;
  
    p = jobs[job]->pipe;
    while (p->next != jobs[job]->pipe)
      p = p->next;
  
    sigsetmask (oldmask);
    return (p->pid);
  }
  
--- 895,918 ----
  lastproc (job)
       int job;
  {
    register PROCESS *p;
+ #ifndef _POSIX_SOURCE
+   int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    p = jobs[job]->pipe;
    while (p->next != jobs[job]->pipe)
      p = p->next;
  
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
    return (p->pid);
  }
  
***************
*** 856,862 ****
--- 942,954 ----
    while (1)
      {
        register int i, count = 0;
+ #ifndef _POSIX_SOURCE
        int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+ 	  sigset_t oldmask, newmask;
+ 	  newmask = sigmask(SIGCHLD);
+ 	  sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
        for (i = 0; i < job_slots; i++)
  	if (jobs[i] && (JOBSTATE (i) == JRUNNING) && !(jobs[i]->foreground))
***************
*** 867,873 ****
  
        if (!count)
  	{
! 	  sigsetmask (oldmask);
  	  break;
  	}
  
--- 959,969 ----
  
        if (!count)
  	{
! #ifndef _POSIX_SOURCE
!   	  sigsetmask (oldmask);
! #else
!  	  sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  	  break;
  	}
  
***************
*** 875,881 ****
  	if (jobs[i] && (JOBSTATE (i) == JRUNNING) && !jobs[i]->foreground)
  	  {
  	    int pid = jobs[i]->pgrp;
! 	    sigsetmask (oldmask);
  	    QUIT;
  	    wait_for_single_pid (pid);
  	    break;
--- 971,981 ----
  	if (jobs[i] && (JOBSTATE (i) == JRUNNING) && !jobs[i]->foreground)
  	  {
  	    int pid = jobs[i]->pgrp;
! #ifndef _POSIX_SOURCE
!   		sigsetmask (oldmask);
! #else
! 		sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  	    QUIT;
  	    wait_for_single_pid (pid);
  	    break;
***************
*** 888,899 ****
  wait_for (pid)
       int pid;
  {
!   int oldmask, job, termination_state;
    register PROCESS *child;
    extern char *sys_siglist[];
    extern int interactive;
  
    oldmask = sigblock (sigmask (SIGCHLD));
  
    /* If we say wait_for (), then we have a record of this child somewhere.
       If this child and all of its peers are not running, then don't
--- 988,1007 ----
  wait_for (pid)
       int pid;
  {
!   int job, termination_state;
    register PROCESS *child;
    extern char *sys_siglist[];
    extern int interactive;
  
+ #ifndef _POSIX_SOURCE
+   int oldmask;
    oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask,nullmask;
+   nullmask=(sigset_t) 0;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    /* If we say wait_for (), then we have a record of this child somewhere.
       If this child and all of its peers are not running, then don't
***************
*** 943,949 ****
--- 1051,1062 ----
    if (child->running ||
        ((job != NO_JOB) && (JOBSTATE (job) == JRUNNING)))
      {
+ #ifndef _POSIX_SOURCE
        sigpause ((long)0);
+ #else
+ 	  sigsuspend(&nullmask);
+ #endif /* _POSIX_SOURCE */
+ 
        goto wait_loop;
      }
  
***************
*** 977,983 ****
--- 1090,1100 ----
      notify_and_cleanup ();
  
   wait_exit:
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
    return (termination_state);
  }
  
***************
*** 1007,1013 ****
--- 1124,1136 ----
       JOB_STATE state;
  {
    register int i;
+ #ifndef _POSIX_SOURCE
    int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    for (i = job - 1; i >= 0; i--)
      {
***************
*** 1016,1027 ****
  	  if (JOBSTATE (i) == state)
  	    {
  	      /* Found it! */
! 	      sigsetmask (oldmask);
  	      return (i);
  	    }
  	}
      }
    sigsetmask (oldmask);
    return (NO_JOB);
  }
  
--- 1139,1158 ----
  	  if (JOBSTATE (i) == state)
  	    {
  	      /* Found it! */
! #ifndef _POSIX_SOURCE
!   sigsetmask (oldmask);
! #else
!   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
  	      return (i);
  	    }
  	}
      }
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
    return (NO_JOB);
  }
  
***************
*** 1132,1140 ****
  start_job (job, foreground)
       int job, foreground;
  {
-   int oldmask = sigblock (sigmask (SIGCHLD));
    int already_running = (JOBSTATE (job) == JRUNNING);
    register PROCESS *p;
  
    if (!foreground && already_running)
      {
--- 1263,1277 ----
  start_job (job, foreground)
       int job, foreground;
  {
    int already_running = (JOBSTATE (job) == JRUNNING);
    register PROCESS *p;
+ #ifndef _POSIX_SOURCE
+   int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    if (!foreground && already_running)
      {
***************
*** 1204,1213 ****
--- 1341,1358 ----
    if (!already_running)
      {
        jobs[job]->notified = 1;
+ #ifndef _POSIX_SOURCE
        killpg (jobs[job]->pgrp, SIGCONT);
+ #else
+ 	  kill( -(jobs[job]->pgrp), SIGCONT);
+ #endif
      }
  
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  
    if (foreground)
      {
***************
*** 1229,1238 ****
  kill_pid (pid, signal, group)
       int pid, signal, group;
  {
-   int old_mask = sigblock (sigmask (SIGCHLD));
    register PROCESS *p = find_pipeline (pid);
    int job = find_job (pid);
    int result = EXECUTION_SUCCESS;
  
    if (group)
      {
--- 1374,1389 ----
  kill_pid (pid, signal, group)
       int pid, signal, group;
  {
    register PROCESS *p = find_pipeline (pid);
    int job = find_job (pid);
    int result = EXECUTION_SUCCESS;
+ #ifndef _POSIX_SOURCE
+   int oldmask = sigblock (sigmask (SIGCHLD));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = sigmask(SIGCHLD);
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    if (group)
      {
***************
*** 1257,1269 ****
--- 1408,1429 ----
  	    {
  	      if (p && (JOBSTATE (job) == JSTOPPED) &&
  		  (signal == SIGTERM || signal == SIGHUP))
+ #ifndef _POSIX_SOURCE
  		killpg (jobs[job]->pgrp, SIGCONT);
  	      result = killpg (jobs[job]->pgrp, signal);
+ #else
+ 		kill( -(jobs[job]->pgrp),SIGCONT);
+ 	      result = kill (-(jobs[job]->pgrp), signal);
+ #endif
  	    }
  	}
        else
  	{
+ #ifndef _POSIX_SOURCE
  	  result = killpg (pid, signal);
+ #else
+ 	  result = kill( -(pid), signal);
+ #endif
  	}
      }
    else
***************
*** 1270,1276 ****
      {
        result = kill (pid, signal);
      }
!   sigsetmask (old_mask);
    return (result);
  }
  
--- 1430,1440 ----
      {
        result = kill (pid, signal);
      }
! #ifndef _POSIX_SOURCE
!   sigsetmask (oldmask);
! #else
!   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
    return (result);
  }
  
***************
*** 1283,1299 ****
  {
    union wait status;
  #ifndef hpux
    struct rusage rusage;
  #endif
    PROCESS *child;
    int pid, call_set_current = 0, last_stopped_job = NO_JOB;
- 
    do
      {
! #ifdef hpux
        pid = wait3 (&status, (WNOHANG | WUNTRACED), (int *)0);
  #else
        pid = wait3 (&status, (WNOHANG | WUNTRACED), &rusage);
  #endif /* hpux */
  
        if (pid > 0)
--- 1447,1469 ----
  {
    union wait status;
  #ifndef hpux
+ #ifndef _POSIX_SOURCE
    struct rusage rusage;
  #endif
+ #endif
    PROCESS *child;
    int pid, call_set_current = 0, last_stopped_job = NO_JOB;
    do
      {
! #if defined(hpux)
        pid = wait3 (&status, (WNOHANG | WUNTRACED), (int *)0);
  #else
+ #if defined(_POSIX_SOURCE)
+ 	  pid = waitpid(-1,&status,(WNOHANG | WUNTRACED));
+ #else
+ 	  /* neither hpux nor posix */
        pid = wait3 (&status, (WNOHANG | WUNTRACED), &rusage);
+ #endif /* _POSIX_SOURCE */
  #endif /* hpux */
  
        if (pid > 0)
***************
*** 1405,1411 ****
--- 1575,1587 ----
    extern char *sys_siglist[];
    register int job, termsig;
    char *dir = (char *)get_string_value ("PWD");
+ #ifndef _POSIX_SOURCE
    int oldmask = sigblock (sigmask (SIGCHLD) | sigmask (SIGTTOU));
+ #else
+   sigset_t oldmask,newmask;
+   newmask = (sigmask(SIGCHLD) | sigmask(SIGTTOU));
+   sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
  
    for (job = 0; job < job_slots; job++)
      {
***************
*** 1461,1470 ****
  	    }
  	}
      }
    sigsetmask (oldmask);
  }
  
! #ifndef hpux
  add_times (rused)
       struct rusage *rused;
  {
--- 1637,1650 ----
  	    }
  	}
      }
+ #ifndef _POSIX_SOURCE
    sigsetmask (oldmask);
+ #else
+   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
+ #endif
  }
  
! #if !defined(hpux) && !defined(_POSIX_SOURCE)
  add_times (rused)
       struct rusage *rused;
  {
***************
*** 1500,1506 ****
  }
  #endif /* hpux */
  
! #ifdef hpux
  getdtablesize ()
  {
    return (NOFILE);
--- 1680,1686 ----
  }
  #endif /* hpux */
  
! #if defined(hpux)
  getdtablesize ()
  {
    return (NOFILE);
***************
*** 1507,1518 ****
--- 1687,1709 ----
  }
  #endif /* hpux */
  
+ #ifdef _POSIX_SOURCE
+ getdtablesize()
+ {
+   return(sysconf(_SC_OPEN_MAX));
+ }
+ #endif /* _POSIX_SOURCE */
+ 
  /* Initialize the job control mechanism, and set up the tty stuff. */
  initialize_jobs ()
  {
    extern int interactive;
  
+ #ifndef _POSIX_SOURCE
    shell_pgrp = getpgrp (0);
+ #else
+   shell_pgrp = getpgrp ();
+ #endif /* _POSIX_SOURCE */
  
    /* We can only have job control if we are interactive?
       I guess that makes sense. */
***************
*** 1673,1690 ****
  give_terminal_to (pgrp)
       int pgrp;
  {
    int oldmask;
  
    if (job_control)
      {
        oldmask = sigblock (sigmask (SIGTTOU) |
  			  sigmask (SIGTTIN) |
  			  sigmask (SIGTSTP) |
  			  sigmask (SIGCHLD));
  
        terminal_pgrp = pgrp;
        tcsetpgrp (shell_tty, terminal_pgrp);
!       sigsetmask (oldmask);
      }
  }
  
--- 1864,1898 ----
  give_terminal_to (pgrp)
       int pgrp;
  {
+ #ifndef _POSIX_SOURCE
    int oldmask;
+ #else
+   sigset_t oldmask,newmask;
+ #endif
  
    if (job_control)
      {
+ #ifndef _POSIX_SOURCE
        oldmask = sigblock (sigmask (SIGTTOU) |
  			  sigmask (SIGTTIN) |
  			  sigmask (SIGTSTP) |
  			  sigmask (SIGCHLD));
+ #else
+       newmask = sigmask ((SIGTTOU) |
+ 			  sigmask (SIGTTIN) |
+ 			  sigmask (SIGTSTP) |
+ 			  sigmask (SIGCHLD));
+ 	  sigprocmask(SIG_BLOCK,&newmask,&oldmask);
+ #endif
+ 
  
        terminal_pgrp = pgrp;
        tcsetpgrp (shell_tty, terminal_pgrp);
! #ifndef _POSIX_SOURCE
!   sigsetmask (oldmask);
! #else
!   sigprocmask(SIG_SETMASK,&oldmask,(sigset_t *)0);
! #endif
      }
  }
  
diff -c bash-1.05/readline/ChangeLog bash-1.05.new/readline/ChangeLog
*** bash-1.05/readline/ChangeLog	Sat Feb 17 17:00:42 1990
--- bash-1.05.new/readline/ChangeLog	Wed Jan 16 23:25:49 1991
***************
*** 1,3 ****
--- 1,10 ----
+ 
+ Wed Jan 16 23:23:32 MET 1991 Heiko Blume (src at scuzzy.in-berlin.de)
+ 
+ 	* readline.c: use S_ISDIR if _POSIX_SOURCE is defined.
+ 	also don't declare 'struct passwd *getpwuid()' then,
+ 	that's in pwd.h already.
+ 
  Wed Jan 17 19:24:09 1990  Brian Fox  (bfox at sbphy.ucsb.edu)
  
  	* history.c: history_expand (); fixed overwriting memory error,
diff -c bash-1.05/readline/readline.c bash-1.05.new/readline/readline.c
*** bash-1.05/readline/readline.c	Sun Feb 25 17:33:07 1990
--- bash-1.05.new/readline/readline.c	Wed Jan 16 15:41:16 1991
***************
*** 33,38 ****
--- 33,41 ----
  #include <stdio.h>
  #include <sys/types.h>
  #include <fcntl.h>
+ #ifdef _POSIX_SOURCE
+ #define O_NDELAY O_NONBLOCK
+ #endif /* _POSIC_SOURCE */
  #include <sys/file.h>
  #include <signal.h>
  
***************
*** 63,69 ****
--- 66,76 ----
  
  #include <pwd.h>
  #ifdef SYSV
+ #ifndef _POSIX_SOURCE
  struct passwd *getpwuid (), *getpwent ();
+ #else
+ struct passwd *getpwent ();
+ #endif /* _POSIX_SOURCE */
  #endif
  
  #define HACK_TERMCAP_MOTION
***************
*** 119,125 ****
  static delete_chars ();
  static insert_some_chars ();
  
! #ifdef VOID_SIGHANDLER
  #define sighandler void
  #else
  #define sighandler int
--- 126,132 ----
  static delete_chars ();
  static insert_some_chars ();
  
! #if defined(VOID_SIGHANDLER) || defined(_POSIX_SOURCE)
  #define sighandler void
  #else
  #define sighandler int
***************
*** 1101,1107 ****
    if (ioctl (tty, TCGETA, &ttybuff) != -1)
      {
        int erase = ttybuff.c_cc[VERASE];
!       int kill = ttybuff.c_cc[VKILL]l
  
        if (erase != -1 && keymap[(unsigned char)erase].type == ISFUNC)
  	keymap[(unsigned char)erase].function = rl_rubout;
--- 1108,1114 ----
    if (ioctl (tty, TCGETA, &ttybuff) != -1)
      {
        int erase = ttybuff.c_cc[VERASE];
!       int kill = ttybuff.c_cc[VKILL];
  
        if (erase != -1 && keymap[(unsigned char)erase].type == ISFUNC)
  	keymap[(unsigned char)erase].function = rl_rubout;
***************
*** 3263,3269 ****
--- 3270,3280 ----
  		  char *filename = tilde_expand (matches[0]);
  
  		  if ((stat (filename, &finfo) == 0) &&
+ #ifndef _POSIX_SOURCE
  		      ((finfo.st_mode & S_IFMT) == S_IFDIR))
+ #else
+ 			  (S_ISDIR(finfo.st_mode)))
+ #endif /* _POSIX_SOURCE */
  		    {
  		      if (the_line[rl_point] != '/')
  			rl_insert_text ("/");
*** bash-1.05/shell.c	Wed Jan 16 22:53:44 1991
--- bash-1.05.new/shell.c	Fri Jan  4 15:42:09 1991
***************
*** 53,60 ****
--- 53,62 ----
  #include "flags.h"
  
  #ifdef SYSV
+ #ifndef _POSIX_SOURCE
  struct passwd *getpwuid();
  #endif
+ #endif
  
  extern char *dist_version;
  extern int build_version;
***************
*** 127,133 ****
--- 129,139 ----
  
  /* The environment at the top-level REP loop.  We use this in the case of
     error return. */
+ #ifndef _POSIX_SOURCE
  jmp_buf top_level, catch;
+ #else
+ sigjmp_buf top_level, catch;
+ #endif /* _POSIX_SOURCE */
  
  /* Non-zero is the recursion depth for commands. */
  int indirection_level = 0;
***************
*** 198,204 ****
--- 204,214 ----
    if (shell_initialized)
      {
        shell_reinitialize ();
+ #ifndef _POSIX_SOURCE
        if (setjmp (top_level))
+ #else
+       if (sigsetjmp (top_level,1))
+ #endif /* _POSIX_SOURCE */
  	exit (2);
      }
  
***************
*** 340,346 ****
--- 350,360 ----
    /* Give this shell a place to longjmp to before executing the
       startup files.  This allows users to press C-c to abort the
       lengthy startup. */
+ #ifndef _POSIX_SOURCE
    if (setjmp (top_level))
+ #else
+   if (sigsetjmp (top_level,1))
+ #endif /* _POSIX_SOURCE */
      {
        if (!interactive)
  	exit (2);
***************
*** 588,594 ****
--- 602,612 ----
    while (!EOF_Reached)
      {
        sighandler sigint_sighandler ();
+ #ifndef _POSIX_SOURCE
        int code = setjmp (top_level);
+ #else
+       int code = sigsetjmp (top_level,1);
+ #endif /* _POSIX_SOURCE */
  
        signal (SIGINT, sigint_sighandler);
  
***************
*** 885,894 ****
--- 903,919 ----
  
    last_command_exit_value |= 128;
  
+ #ifndef _POSIX_SOURCE
    if (interactive)
      longjmp (top_level, DISCARD);
    else
      longjmp (top_level, EXITPROG);
+ #else
+   if (interactive)
+     siglongjmp (top_level, DISCARD);
+   else
+     siglongjmp (top_level, EXITPROG);
+ #endif /* _POSIX_SOURCE */
  }
  
  /* When non-zero, we throw_to_top_level (). */
***************
*** 898,903 ****
--- 923,934 ----
  sighandler
  sigint_sighandler ()
  {
+ #ifndef _POSIX_SOURCE
+   /* src@scuzzy.in-berlin.de: this call shouldn't be
+    * necessary with sigset(2P) used in the first place.
+    */
+   signal (SIGINT, sigint_sighandler); /* Re-establish right now!!! */
+ #endif /* _POSIX_SOURCE */
    if (interrupt_immediately)
      {
        interrupt_immediately = 0;
*** bash-1.05/shell.h	Sun Feb 25 16:46:14 1990
--- bash-1.05.new/shell.h	Wed Jan 16 15:18:52 1991
***************
*** 5,11 ****
  #include "variables.h"
  #include "quit.h"
  
! #ifdef SYSV
  #define MAXPATHLEN 1024
  #endif
  
--- 5,11 ----
  #include "variables.h"
  #include "quit.h"
  
! #if defined(SYSV)
  #define MAXPATHLEN 1024
  #endif
  
***************
*** 20,26 ****
--- 20,30 ----
  /* A bunch of stuff for flow of control using setjmp () and longjmp (). */
  
  #include <setjmp.h>
+ #ifndef _POSIX_SOURCE
  extern jmp_buf top_level, catch;
+ #else
+ extern sigjmp_buf top_level, catch;
+ #endif
  
  #define NOT_JUMPED 0		/* Not returning from a longjmp. */
  #define FORCE_EOF 1		/* We want to stop parsing. */
*** bash-1.05/subst.c	Wed Jan 16 22:53:45 1991
--- bash-1.05.new/subst.c	Fri Jan  4 15:42:09 1991
***************
*** 224,230 ****
--- 224,234 ----
      {
        report_error ("Bad command substitution: `$(%s'", result);
        free (result);
+ #ifndef _POSIX_SOURCE
        longjmp (top_level, DISCARD);
+ #else
+       siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
      }
  
    return (result);
***************
*** 912,918 ****
--- 916,926 ----
  	    case '\0':
  	    bad_substitution:
  	      report_error ("%s: bad substitution", name ? name : "??");
+ #ifndef _POSIX_SOURCE
  	      longjmp (top_level, DISCARD);
+ #else
+ 	      siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  
  	    case '}':
  	      break;
***************
*** 1052,1061 ****
--- 1060,1076 ----
  		  if (temp)
  		    free (temp);
  
+ #ifndef _POSIX_SOURCE
  		  if (!interactive)
  		    longjmp (top_level, FORCE_EOF);
  		  else
  		    longjmp (top_level, DISCARD);
+ #else
+ 		  if (!interactive)
+ 		    siglongjmp (top_level, FORCE_EOF);
+ 		  else
+ 		    siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  		}
  	      break;
  	    
***************
*** 1141,1147 ****
--- 1156,1166 ----
  		goto add_string;
  	    }
  	  free (name);
+ #ifndef _POSIX_SOURCE
  	  longjmp (top_level, DISCARD);
+ #else
+ 	  siglongjmp (top_level, DISCARD);
+ #endif /* _POSIX_SOURCE */
  	}
        }
        break;			/* End case '$': */
*** bash-1.05/test.c	Wed Jan 17 01:31:07 1990
--- bash-1.05.new/test.c	Fri Jan  4 15:42:09 1991
***************
*** 72,80 ****
--- 72,86 ----
  #define test_exit(val) exit (val)
  #else
  #include <setjmp.h>
+ #ifndef _POSIX_SOURCE
  jmp_buf test_exit_buf;
  int test_error_return = 0;
  #define test_exit(val) test_error_return = val, longjmp (test_exit_buf, 1)
+ #else
+ sigjmp_buf test_exit_buf;
+ int test_error_return = 0;
+ #define test_exit(val) test_error_return = val, siglongjmp (test_exit_buf, 1)
+ #endif /* _POSIX_SOURCE */
  #endif /* STANDALONE */
  
  #ifdef SYSV
***************
*** 541,550 ****
--- 547,564 ----
  	   * to see if the given file is not a directory.
  	   */
  	  if (sys_v)
+ #ifndef _POSIX_SOURCE
  	    return (TRUE == ((S_IFREG == (stat_buf.st_mode & S_IFMT)) ||
  			     (0 == (stat_buf.st_mode & S_IFMT))));
+ #else
+ 	    return (TRUE == (S_ISREG(stat_buf.st_mode)));
+ #endif
  	  else
+ #ifndef _POSIX_SOURCE
  	    return (TRUE == (S_IFDIR != (stat_buf.st_mode & S_IFMT)));
+ #else
+ 		return (TRUE == (!S_ISDIR(stat_buf.st_mode)));
+ #endif /* _POSIX_SOURCE */
  
  	case 'd':		/* File is a directory? */
  	  unary_advance ();
***************
*** 551,557 ****
--- 565,575 ----
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  
+ #ifndef _POSIX_SOURCE
  	  return (TRUE == (S_IFDIR == (stat_buf.st_mode & S_IFMT)));
+ #else
+ 	  return (TRUE == (S_ISDIR(stat_buf.st_mode)));
+ #endif
  
  	case 's':		/* File has something in it? */
  	  unary_advance ();
***************
*** 574,580 ****
--- 592,602 ----
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  
+ #ifndef _POSIX_SOURCE
  	  return (TRUE == (S_IFCHR == (stat_buf.st_mode & S_IFMT)));
+ #else
+ 	  return (TRUE == (S_ISCHR(stat_buf.st_mode)));
+ #endif
  
  	case 'b':		/* File is block special? */
  	  unary_advance ();
***************
*** 581,596 ****
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  
  	  return (TRUE == (S_IFBLK == (stat_buf.st_mode & S_IFMT)));
  
  	case 'p':		/* File is a named pipe? */
  	  unary_advance ();
! #ifndef S_IFIFO
  	  return (FALSE);
  #else
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  	  return (TRUE == (S_IFIFO == (stat_buf.st_mode & S_IFMT)));
  #endif /* S_IFIFO */
  
  	case 'L':		/* Same as -h  */
--- 603,626 ----
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  
+ #ifndef _POSIX_SOURCE
  	  return (TRUE == (S_IFBLK == (stat_buf.st_mode & S_IFMT)));
+ #else
+ 	  return (TRUE == (S_ISBLK(stat_buf.st_mode)));
+ #endif
  
  	case 'p':		/* File is a named pipe? */
  	  unary_advance ();
! #if !defined(S_IFIFO) && !defined(S_ISFIFO)
  	  return (FALSE);
  #else
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
+ #ifndef _POSIX_SOURCE
  	  return (TRUE == (S_IFIFO == (stat_buf.st_mode & S_IFMT)));
+ #else /* _POSIX_SOURCE */
+ 	  return (TRUE == (S_ISFIFO(stat_buf.st_mode)));
+ #endif /* _POSIX_SOURCE */
  #endif /* S_IFIFO */
  
  	case 'L':		/* Same as -h  */
***************
*** 622,631 ****
--- 652,665 ----
  	  return (TRUE == (0 != (stat_buf.st_mode & S_ISGID)));
  
  	case 'k':		/* File has sticky bit set? */
+ #ifndef S_ISVTX
+ 	  return(FALSE);
+ #else
  	  unary_advance ();
  	  if (stat (argv[pos - 1], &stat_buf) < 0)
  	    return (FALSE);
  	  return (TRUE == (0 != (stat_buf.st_mode & S_ISVTX)));
+ #endif /* S_ISVTX */
  
  	case 't':		/* File (fd) is a terminal?  (fd) defaults to stdout. */
  	  advance (0);
***************
*** 724,730 ****
--- 758,768 ----
    auto int value;
    int expr ();
  #ifndef STANDALONE
+ #ifndef _POSIX_SOURCE
    int code = setjmp (test_exit_buf);
+ #else
+   int code = sigsetjmp (test_exit_buf,1);
+ #endif /* _POSIX_SOURCE */
  
    if (code)
      return (test_error_return);
*** bash-1.05/variables.c	Wed Jan 16 22:53:46 1991
--- bash-1.05.new/variables.c	Fri Jan  4 15:42:09 1991
***************
*** 27,33 ****
--- 27,35 ----
  #include "version.h"
  
  #ifdef SYSV
+ #ifndef _POSIX_SOURCE
  struct passwd *getpwuid (), *getpwent ();
+ #endif
  #endif
  
  /* The list of shell variables that the user has created, or that came from
*** bash-1.05/version.h	Wed Jan 16 22:53:46 1991
--- bash-1.05.new/version.h	Wed Jan 16 15:48:25 1991
***************
*** 5,8 ****
  #define DISTVERSION "1.05"
  
  /* The last built version of this shell. */
! #define BUILDVERSION 14
--- 5,8 ----
  #define DISTVERSION "1.05"
  
  /* The last built version of this shell. */
! #define BUILDVERSION 85
-- 
      Heiko Blume <-+-> src@scuzzy.in-berlin.de <-+-> (+49 30) 691 88 93
                    public source archive [HST V.42bis]:
        scuzzy Any ACU,f 38400 6919520 gin:--gin: nuucp sword: nuucp
                     uucp scuzzy!/src/README /your/home