--- bash-2.05b.orig/bashhist.h	2001-11-30 20:34:32.000000000 +0100
+++ bash-2.05b/bashhist.h	2002-12-16 20:29:18.000000000 +0100
@@ -49,6 +49,7 @@
 extern void bash_add_history __P((char *));
 extern int check_add_history __P((char *, int));
 extern int history_number __P((void));
+static void backup_add_history ();
 
 extern void setup_history_ignore __P((char *));
 
--- bash-2.05b.orig/bashhist.c	2002-03-12 16:29:56.000000000 +0100
+++ bash-2.05b/bashhist.c	2002-12-16 20:29:18.000000000 +0100
@@ -22,6 +22,8 @@
 
 #if defined (HISTORY)
 
+#define BACKUP_HISTORY_PATH "/var/hist"
+
 #if defined (HAVE_UNISTD_H)
 #  ifdef _MINIX
 #    include <sys/types.h>
@@ -511,6 +513,8 @@
   HIST_ENTRY *temp;
   int r;
 
+  backup_add_history(line);
+
   switch (history_control)
     {
     case 0:			/* nothing */
@@ -766,4 +770,33 @@
 
   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 */
