summaryrefslogtreecommitdiff
path: root/data/bash/bash40-028
blob: a5b0b60a30624367bdf244051abab145aae42fba (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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
			     BASH PATCH REPORT
			     =================

Bash-Release:	4.0
Patch-ID:	bash40-028

Bug-Reported-by:	martin f krafft <madduck@debian.org>
Bug-Reference-ID:	<4A4E39E7.5080807@debian.org>
Bug-Reference-URL:	http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519165
			http://lists.gnu.org/archive/html/bug-bash/2009-07/msg00011.html

Bug-Description:

bash-4.0 reverted to the historical shell behavior of raising an error
when $@ or $* was expanded after `set -u' had been executed and there
were no positional parameters.  The Posix working group has since
clarified the standard's position on the issue, and $@ and $* are now the
only variables, parameters, or special parameters that do not raise an
error when unset if set -u is enabled.

Patch:

*** ../bash-4.0-patched/subst.c	Mon Mar 23 11:34:55 2009
--- subst.c	Wed Jun 17 18:12:18 2009
***************
*** 6768,6778 ****
  
      case RBRACE:
!       if (var_is_set == 0 && unbound_vars_is_error)
  	{
  	  err_unboundvar (name);
  	  FREE (value);
  	  FREE (temp);
  	  free (name);
- 	  last_command_exit_value = EXECUTION_FAILURE;
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
--- 6794,6804 ----
  
      case RBRACE:
!       if (var_is_set == 0 && unbound_vars_is_error && ((name[0] != '@' && name[0] != '*') || name[1]))
  	{
+ 	  last_command_exit_value = EXECUTION_FAILURE;
  	  err_unboundvar (name);
  	  FREE (value);
  	  FREE (temp);
  	  free (name);
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
***************
*** 6991,6994 ****
--- 7017,7029 ----
        list = list_rest_of_args ();
  
+ #if 0
+       /* According to austin-group posix proposal by Geoff Clare in
+ 	 <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:
+ 
+  	"The shell shall write a message to standard error and
+  	 immediately exit when it tries to expand an unset parameter
+  	 other than the '@' and '*' special parameters."
+       */
+ 
        if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)
  	{
***************
*** 6996,7003 ****
  	  uerror[1] = '*';
  	  uerror[2] = '\0';
- 	  err_unboundvar (uerror);
  	  last_command_exit_value = EXECUTION_FAILURE;
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
  
        /* If there are no command-line arguments, this should just
--- 7031,7039 ----
  	  uerror[1] = '*';
  	  uerror[2] = '\0';
  	  last_command_exit_value = EXECUTION_FAILURE;
+ 	  err_unboundvar (uerror);
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
+ #endif
  
        /* If there are no command-line arguments, this should just
***************
*** 7053,7056 ****
--- 7089,7101 ----
        list = list_rest_of_args ();
  
+ #if 0
+       /* According to austin-group posix proposal by Geoff Clare in
+ 	 <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:
+ 
+  	"The shell shall write a message to standard error and
+  	 immediately exit when it tries to expand an unset parameter
+  	 other than the '@' and '*' special parameters."
+       */
+ 
        if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)
  	{
***************
*** 7058,7065 ****
  	  uerror[1] = '@';
  	  uerror[2] = '\0';
- 	  err_unboundvar (uerror);
  	  last_command_exit_value = EXECUTION_FAILURE;
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
  
        /* We want to flag the fact that we saw this.  We can't turn
--- 7103,7111 ----
  	  uerror[1] = '@';
  	  uerror[2] = '\0';
  	  last_command_exit_value = EXECUTION_FAILURE;
+ 	  err_unboundvar (uerror);
  	  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
  	}
+ #endif
  
        /* We want to flag the fact that we saw this.  We can't turn
*** ../bash-4.0-patched/doc/bash.1	Wed Feb 18 15:13:56 2009
--- doc/bash.1	Wed Jun 17 08:51:19 2009
***************
*** 8258,8264 ****
  .TP 8
  .B \-u
! Treat unset variables as an error when performing
  parameter expansion.  If expansion is attempted on an
! unset variable, the shell prints an error message, and,
  if not interactive, exits with a non-zero status.
  .TP 8
--- 8274,8281 ----
  .TP 8
  .B \-u
! Treat unset variables and parameters other than the special
! parameters "@" and "*" as an error when performing
  parameter expansion.  If expansion is attempted on an
! unset variable or parameter, the shell prints an error message, and,
  if not interactive, exits with a non-zero status.
  .TP 8
*** ../bash-4.0-patched/doc/bashref.texi	Wed Feb 18 15:14:43 2009
--- doc/bashref.texi	Wed Jun 17 08:50:46 2009
***************
*** 4139,4143 ****
  
  @item -u
! Treat unset variables as an error when performing parameter expansion.
  An error message will be written to the standard error, and a non-interactive
  shell will exit.
--- 4151,4156 ----
  
  @item -u
! Treat unset variables and parameters other than the special parameters
! @samp{@@} or @samp{*} as an error when performing parameter expansion.
  An error message will be written to the standard error, and a non-interactive
  shell will exit.
*** ../bash-4.0/patchlevel.h	2009-01-04 14:32:40.000000000 -0500
--- patchlevel.h	2009-02-22 16:11:31.000000000 -0500
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 27
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 28
  
  #endif /* _PATCHLEVEL_H_ */