--- bash-2.05.orig/bashhist.c	Thu Sep 13 19:36:17 2001
+++ bash-2.05/bashhist.c	Thu Sep 13 19:48:37 2001
@@ -22,6 +22,8 @@
 
 #if defined (HISTORY)
 
+#define BACKUP_HISTORY_PATH "/var/hist"
+
 #if defined (HAVE_UNISTD_H)
 #  ifdef _MINIX
 #    include <sys/types.h>
@@ -158,6 +160,7 @@
 extern char *history_delimiting_chars ();
 extern void maybe_add_history ();	/* forward declaration */
 extern void bash_add_history ();	/* forward declaration */
+static void backup_add_history ();     /* forward declaration */
 
 static int history_should_ignore ();
 
@@ -493,6 +496,8 @@
   static int first_line_saved = 0;
   HIST_ENTRY *temp;
 
+  backup_add_history(line);
+
   hist_last_line_added = 0;
 
   /* Don't use the value of history_control to affect the second
@@ -715,4 +720,34 @@
 
   return match;
 }
+
+static void
+backup_add_history (line)
+       char *line;
+{
+  char filename[PATH_MAX], buf[128];
+  struct tm *tm;
+  time_t t;
+  int fd;
+
+  snprintf(filename, sizeof(filename), "%s/%s", BACKUP_HISTORY_PATH,
+    current_user.user_name);
+
+  if ((fd = open(filename, O_CREAT | O_WRONLY | O_APPEND, 0600)) == -1)
+    return;
+
+  t = time(NULL);
+  tm = localtime(&t);
+
+  strftime(buf, sizeof(buf), "%b %e %T ", tm);
+  write(fd, buf, strlen(buf));
+  snprintf(buf, sizeof(buf), "(%d): ", getpid());
+  write(fd, buf, strlen(buf));
+  write(fd, line, strlen(line));
+  write(fd, "\n", 1);
+
+  close(fd);
+}
+
+
 #endif /* HISTORY */
