chiark / gitweb /
bash (4.2+dfsg-0.1) unstable; urgency=low
[bash.git] / debian / patches / bash42-005.diff
1 # DP: bash-4.2 upstream patch 005
2
3                              BASH PATCH REPORT
4                              =================
5
6 Bash-Release:   4.2
7 Patch-ID:       bash42-005
8
9 Bug-Reported-by:        Dennis Williamson <dennistwilliamson@gmail.com>
10 Bug-Reference-ID:       <AANLkTikDbEV5rnbPc0zOfmZfBcg0xGetzLLzK+KjRiNa@mail.gmail.com>
11 Bug-Reference-URL:      http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00147.html
12
13 Bug-Description:
14
15 Systems that use tzset() to set the local timezone require the TZ variable
16 to be in the environment.  Bash must make sure the environment has been
17 modified with any updated value for TZ before calling tzset().  This
18 affects prompt string expansions and the `%T' printf conversion specification
19 on systems that do not allow bash to supply a replacement for getenv(3).
20
21 Patch (apply with `patch -p0'):
22
23 --- a/bash/builtins/printf.def
24 +++ b/bash/builtins/printf.def
25 @@ -465,6 +465,9 @@
26                   secs = shell_start_time;      /* roughly $SECONDS */
27                 else
28                   secs = arg;
29 +#if defined (HAVE_TZSET)
30 +               sv_tz ("TZ");           /* XXX -- just make sure */
31 +#endif
32                 tm = localtime (&secs);
33                 n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
34                 free (timefmt);
35 --- a/bash/parse.y
36 +++ b/bash/parse.y
37 @@ -5135,6 +5135,9 @@
38             case 'A':
39               /* Make the current time/date into a string. */
40               (void) time (&the_time);
41 +#if defined (HAVE_TZSET)
42 +             sv_tz ("TZ");             /* XXX -- just make sure */
43 +#endif
44               tm = localtime (&the_time);
45  
46               if (c == 'd')
47 --- a/bash/patchlevel.h
48 +++ b/bash/patchlevel.h
49 @@ -25,6 +25,6 @@
50     regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
51     looks for to find the patch level (for the sccs version string). */
52  
53 -#define PATCHLEVEL 4
54 +#define PATCHLEVEL 5
55  
56  #endif /* _PATCHLEVEL_H_ */
57 --- a/bash/variables.c
58 +++ b/bash/variables.c
59 @@ -3653,6 +3653,22 @@
60    return n;
61  }
62  
63 +int
64 +chkexport (name)
65 +     char *name;
66 +{
67 +  SHELL_VAR *v;
68 +
69 +  v = find_variable (name);
70 +  if (exported_p (v))
71 +    {
72 +      array_needs_making = 1;
73 +      maybe_make_export_env ();
74 +      return 1;
75 +    }
76 +  return 0;
77 +}
78 +
79  void
80  maybe_make_export_env ()
81  {
82 @@ -4214,7 +4230,7 @@
83    { "TEXTDOMAIN", sv_locale },
84    { "TEXTDOMAINDIR", sv_locale },
85  
86 -#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
87 +#if defined (HAVE_TZSET)
88    { "TZ", sv_tz },
89  #endif
90  
91 @@ -4558,12 +4574,13 @@
92  }
93  #endif /* HISTORY */
94  
95 -#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
96 +#if defined (HAVE_TZSET)
97  void
98  sv_tz (name)
99       char *name;
100  {
101 -  tzset ();
102 +  if (chkexport (name))
103 +    tzset ();
104  }
105  #endif
106  
107 --- a/bash/variables.h
108 +++ b/bash/variables.h
109 @@ -313,6 +313,7 @@
110  
111  extern void sort_variables __P((SHELL_VAR **));
112  
113 +extern int chkexport __P((char *));
114  extern void maybe_make_export_env __P((void));
115  extern void update_export_env_inplace __P((char *, int, char *));
116  extern void put_command_name_into_env __P((char *));