]> git.pld-linux.org Git - packages/bash.git/blob - bash-backup_history.patch
- there is no need to drop nxterm
[packages/bash.git] / bash-backup_history.patch
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
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>
12 @@ -175,6 +177,8 @@
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? */
21 @@ -511,6 +515,10 @@
22    HIST_ENTRY *temp;
23    int r;
24  
25 +
26 + backup_add_history(line);
27
28
29    switch (history_control)
30      {
31      case 0:                    /* nothing */
32 @@ -766,4 +774,34 @@
33  
34    return match;
35  }
36 +
37 +static void
38 +backup_add_history (line)
39 +       char *line;
40 +{
41 +  char filename[PATH_MAX], buf[128];
42 +  struct tm *tm;
43 +  time_t t;
44 +  int fd;
45 +
46 +  snprintf(filename, sizeof(filename), "%s/%s", BACKUP_HISTORY_PATH,
47 +    current_user.user_name);
48 +
49 +  if ((fd = open(filename, O_CREAT | O_WRONLY | O_APPEND, 0600)) == -1)
50 +    return;
51 +
52 +  t = time(NULL);
53 +  tm = localtime(&t);
54 +
55 +  strftime(buf, sizeof(buf), "%b %e %T ", tm);
56 +  write(fd, buf, strlen(buf));
57 +  snprintf(buf, sizeof(buf), "(%d): ", getpid());
58 +  write(fd, buf, strlen(buf));
59 +  write(fd, line, strlen(line));
60 +  write(fd, "\n", 1);
61 +
62 +  close(fd);
63 +}
64 +
65 +
66  #endif /* HISTORY */
This page took 0.029008 seconds and 3 git commands to generate.