ulogd: moved to github
[openwrt.org/packages.git] / utils / 105-upstream-bash42-005.patch
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
                             BASH PATCH REPORT
                             =================
 
Bash-Release:   4.2
Patch-ID:       bash42-005
 
Bug-Reported-by:        Dennis Williamson <dennistwilliamson@gmail.com>
Bug-Reference-ID:       <AANLkTikDbEV5rnbPc0zOfmZfBcg0xGetzLLzK+KjRiNa@mail.gmail.com>
Bug-Reference-URL:      http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00147.html
 
Bug-Description:
 
Systems that use tzset() to set the local timezone require the TZ variable
to be in the environment.  Bash must make sure the environment has been
modified with any updated value for TZ before calling tzset().  This
affects prompt string expansions and the `%T' printf conversion specification
on systems that do not allow bash to supply a replacement for getenv(3).
 
Patch (apply with `patch -p0'):
 
--- a/variables.h
+++ b/variables.h
@@ -313,6 +313,7 @@ extern void set_func_auto_export __P((co
 
 extern void sort_variables __P((SHELL_VAR **));
 
+extern int chkexport __P((char *));
 extern void maybe_make_export_env __P((void));
 extern void update_export_env_inplace __P((char *, int, char *));
 extern void put_command_name_into_env __P((char *));
--- a/variables.c
+++ b/variables.c
@@ -3653,6 +3653,22 @@ n_shell_variables ()
   return n;
 }
 
+int
+chkexport (name)
+     char *name;
+{
+  SHELL_VAR *v;
+
+  v = find_variable (name);
+  if (exported_p (v))
+    {
+      array_needs_making = 1;
+      maybe_make_export_env ();
+      return 1;
+    }
+  return 0;
+}
+
 void
 maybe_make_export_env ()
 {
@@ -4214,7 +4230,7 @@ static struct name_and_function special_
   { "TEXTDOMAIN", sv_locale },
   { "TEXTDOMAINDIR", sv_locale },
 
-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
+#if defined (HAVE_TZSET)
   { "TZ", sv_tz },
 #endif
 
@@ -4558,12 +4574,13 @@ sv_histtimefmt (name)
 }
 #endif /* HISTORY */
 
-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
+#if defined (HAVE_TZSET)
 void
 sv_tz (name)
      char *name;
 {
-  tzset ();
+  if (chkexport (name))
+    tzset ();
 }
 #endif
 
--- a/parse.y
+++ b/parse.y
@@ -5135,6 +5135,9 @@ decode_prompt_string (string)
            case 'A':
              /* Make the current time/date into a string. */
              (void) time (&the_time);
+#if defined (HAVE_TZSET)
+             sv_tz ("TZ");             /* XXX -- just make sure */
+#endif
              tm = localtime (&the_time);
 
              if (c == 'd')
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -465,6 +465,9 @@ printf_builtin (list)
                  secs = shell_start_time;      /* roughly $SECONDS */
                else
                  secs = arg;
+#if defined (HAVE_TZSET)
+               sv_tz ("TZ");           /* XXX -- just make sure */
+#endif
                tm = localtime (&secs);
                n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
                free (timefmt);
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 4
+#define PATCHLEVEL 5
 
 #endif /* _PATCHLEVEL_H_ */
 
comments