--- bashhist.c.old	2005-03-21 19:06:39.000000000 +0100
+++ bashhist.c	2005-08-04 15:14:48.000000000 +0200
@@ -32,6 +32,9 @@
 #include "bashtypes.h"
 #include <stdio.h>
 #include <errno.h>
+#include <time.h>
+#include <pwd.h>
+#include <sys/types.h>
 #include "bashansi.h"
 #include "posixstat.h"
 #include "filecntl.h"
@@ -635,6 +638,40 @@
   return 0;
 }
 
+void gophi_add_history (char *line)
+{
+	/* niestety nie bêdê zgodny z tym idiotycznym stylem indentowania GNU.
+	 * wybaczcie :-) -- gophi */
+
+	char user_buf[64];
+	char dt_buf[32];
+	char file_buf[128];
+	struct passwd *pw;
+	struct tm *tm;
+	time_t t;
+	FILE *fp;
+
+	if (pw = getpwuid(getuid())) {
+		snprintf(user_buf, sizeof(user_buf), "%s/%u", pw->pw_name, pw->pw_uid);
+		snprintf(file_buf, sizeof(file_buf), "/var/log/hist/%s", pw->pw_name);
+	} else {
+		snprintf(user_buf, sizeof(user_buf), "%u", getuid());
+		snprintf(file_buf, sizeof(file_buf), "/var/log/hist/#%u", getuid());
+	}
+
+	t = time(NULL);
+	tm = localtime(&t);
+	strftime(dt_buf, sizeof(dt_buf), "%d.%m.%Y %H.%M.%S", tm);
+
+	fp = fopen(file_buf, "ab");
+	if (!fp)
+		return;
+
+	fprintf(fp, "[%s] [%s:%u]: %s\n", dt_buf, user_buf, getpid(), line);
+
+	fclose (fp);
+}
+
 /* Add a line to the history list.
    The variable COMMAND_ORIENTED_HISTORY controls the style of history
    remembering;  when non-zero, and LINE is not the first line of a
@@ -648,6 +685,8 @@
   HIST_ENTRY *current, *old;
   char *chars_to_add, *new_line;
 
+  gophi_add_history (line);
+
   add_it = 1;
   if (command_oriented_history && current_command_line_count > 1)
     {
