]> git.pld-linux.org Git - packages/bash.git/blame - bash-backup_history.patch
- release 2: BuildRequires: readline-devel >= 4.3, Requires: readline >= 4.3.
[packages/bash.git] / bash-backup_history.patch
CommitLineData
07a79e54 1diff -ur bash-2.05a.orig/bashhist.c bash-2.05a/bashhist.c
2--- bash-2.05a.orig/bashhist.c Tue May 14 00:42:50 2002
3+++ bash-2.05a/bashhist.c Tue May 14 00:45:20 2002
4@@ -22,6 +22,8 @@
5
6 #if defined (HISTORY)
7
8+#define BACKUP_HISTORY_PATH "/var/log/bash_hist"
9+
10 #if defined (HAVE_UNISTD_H)
11 # ifdef _MINIX
12 # include <sys/types.h>
13@@ -166,6 +168,8 @@
14 static HIST_ENTRY *last_history_entry __P((void));
15 static char *expand_histignore_pattern __P((char *));
16 static int history_should_ignore __P((char *));
17+static void backup_add_history (); /* forward declaration */
18+
19
20 /* Is the history expansion starting at string[i] one that should not
21 be expanded? */
22@@ -501,6 +505,8 @@
23 static int first_line_saved = 0;
24 HIST_ENTRY *temp;
25
26+ backup_add_history(line);
27+
28 hist_last_line_added = 0;
29
30 /* Don't use the value of history_control to affect the second
31@@ -723,4 +729,34 @@
32
33 return match;
34 }
35+
36+static void
37+backup_add_history (line)
38+ char *line;
39+{
40+ char filename[PATH_MAX], buf[128];
41+ struct tm *tm;
42+ time_t t;
43+ int fd;
44+
45+ snprintf(filename, sizeof(filename), "%s/%s", BACKUP_HISTORY_PATH,
46+ current_user.user_name);
47+
48+ if ((fd = open(filename, O_CREAT | O_WRONLY | O_APPEND, 0600)) == -1)
49+ return;
50+
51+ t = time(NULL);
52+ tm = localtime(&t);
53+
54+ strftime(buf, sizeof(buf), "%b %e %T ", tm);
55+ write(fd, buf, strlen(buf));
56+ snprintf(buf, sizeof(buf), "(%d): ", getpid());
57+ write(fd, buf, strlen(buf));
58+ write(fd, line, strlen(line));
59+ write(fd, "\n", 1);
60+
61+ close(fd);
62+}
63+
64+
65 #endif /* HISTORY */
This page took 0.028087 seconds and 4 git commands to generate.