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