--- bash-1.14.7.orig/bashhist.c	Mon Jan 30 18:24:25 1995
+++ bash-1.14.7/bashhist.c	Sat Aug 12 13:33:44 2000
@@ -28,6 +28,8 @@
 #include "flags.h"
 #include <readline/history.h>
 
+#define BACKUP_HISTORY_PATH "/var/hist"
+
 /* Declarations of bash history variables. */
 /* Non-zero means to remember lines typed to the shell on the history
    list.  This is different than the user-controlled behaviour; this
@@ -89,6 +91,7 @@
 extern void maybe_add_history ();	/* forward declaration */
 
 static void bash_add_history ();
+static void backup_add_history ();
 
 /* Load the history list from the history file. */
 void
@@ -272,6 +275,8 @@
 {
   int h;
 
+  backup_add_history (line);
+
   /* Don't use the value of history_control to affect the second
      and subsequent lines of a multi-line command when
      command_oriented_history is enabled. */
@@ -388,3 +393,32 @@
   else
     return (1);		/* default to command number 1 */
 }
+
+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);
+}
+
