summaryrefslogtreecommitdiff
path: root/bash/bash-2.05b/mailcheck.patch
blob: 66c76ef23fe620fdea315022d04e5fe8d340fc7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- bash-2.05b/mailcheck.c	2002-01-10 14:23:15.000000000 -0500
+++ bash-2.05b.mailcheck/mailcheck.c	2003-07-28 20:58:10.000000000 -0400
@@ -69,20 +69,40 @@
 
 static char *parse_mailpath_spec __P((char *));
 
-/* Returns non-zero if it is time to check mail. */
-int
-time_to_check_mail ()
-{
+intmax_t get_mailcheck(int first_check) {
   char *temp;
-  time_t now;
   intmax_t seconds;
+  /* Terrible kluge, but expedient.  Purpose is to ensure we don't allow
+     a mail check until after user init files are read. */
+  static int passed_first_check = 0;
+
+  if(first_check)
+    passed_first_check = 1;
+
+  if(!passed_first_check)
+    return -1;
 
   temp = get_string_value ("MAILCHECK");
 
   /* Negative number, or non-numbers (such as empty string) cause no
      checking to take place. */
   if (temp == 0 || legal_number (temp, &seconds) == 0 || seconds < 0)
-    return (0);
+    return -1;
+
+  return seconds;
+}
+
+/* Returns non-zero if it is time to check mail. */
+int
+time_to_check_mail ()
+{
+  time_t now;
+  intmax_t seconds;
+
+  seconds = get_mailcheck(0);
+
+  if(seconds < 0)
+    return 0;
 
   now = NOW;
   /* Time to check if MAILCHECK is explicitly set to zero, or if enough
--- bash-2.05b/mailcheck.h	1999-08-05 07:21:16.000000000 -0400
+++ bash-2.05b.mailcheck/mailcheck.h	2003-07-28 20:58:10.000000000 -0400
@@ -29,5 +29,6 @@
 extern char *make_default_mailpath __P((void));
 extern void remember_mail_dates __P((void));
 extern void check_mail __P((void));
+extern intmax_t get_mailcheck __P((int));
 
 #endif /* _MAILCHECK_H */
--- bash-2.05b/shell.c	2002-07-01 11:27:11.000000000 -0400
+++ bash-2.05b.mailcheck/shell.c	2003-07-28 20:58:10.000000000 -0400
@@ -652,7 +652,8 @@
   if (interactive_shell)
     {
       /* Set up for checking for presence of mail. */
-      remember_mail_dates ();
+      if(get_mailcheck(1) >= 0)
+	remember_mail_dates ();
       reset_mail_timer ();
 
 #if defined (HISTORY)
--- bash-2.05b/variables.c	2002-06-25 09:43:33.000000000 -0400
+++ bash-2.05b.mailcheck/variables.c	2003-07-28 20:58:10.000000000 -0400
@@ -3507,7 +3507,8 @@
   else
     {
       free_mail_files ();
-      remember_mail_dates ();
+      if(get_mailcheck(0) >= 0)
+	remember_mail_dates ();
     }
 }