Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/flags.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | extern int set_job_control (int); | - | ||||||||||||||||||||||||
10 | int mark_modified_vars = 0; | - | ||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | int asynchronous_notification = 0; | - | ||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||
19 | int errexit_flag = 0; | - | ||||||||||||||||||||||||
20 | int exit_immediately_on_error = 0; | - | ||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||
23 | int disallow_filename_globbing = 0; | - | ||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | int place_keywords_in_env = 0; | - | ||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | int read_but_dont_execute = 0; | - | ||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | int just_one_command = 0; | - | ||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | int noclobber = 0; | - | ||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | int unbound_vars_is_error = 0; | - | ||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | int echo_input_at_read = 0; | - | ||||||||||||||||||||||||
47 | int verbose_flag = 0; | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | int echo_command_at_execute = 0; | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | int jobs_m_flag = 0; | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | int forced_interactive = 0; | - | ||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | int no_symbolic_links = 0; | - | ||||||||||||||||||||||||
66 | int no_invisible_vars = 0; | - | ||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | int hashing_enabled = 1; | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | int history_expansion = 1; | - | ||||||||||||||||||||||||
75 | int histexp_flag = 0; | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | int interactive_comments = 1; | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | int restricted = 0; | - | ||||||||||||||||||||||||
87 | int restricted_shell = 0; | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | int privileged_mode = 0; | - | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | int brace_expansion = 1; | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | int function_trace_mode = 0; | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | int error_trace_mode = 0; | - | ||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | int pipefail_opt = 0; | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | const struct flags_alist shell_flags[] = { | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | { 'a', &mark_modified_vars }, | - | ||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||
122 | { 'b', &asynchronous_notification }, | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | { 'e', &errexit_flag }, | - | ||||||||||||||||||||||||
125 | { 'f', &disallow_filename_globbing }, | - | ||||||||||||||||||||||||
126 | { 'h', &hashing_enabled }, | - | ||||||||||||||||||||||||
127 | { 'i', &forced_interactive }, | - | ||||||||||||||||||||||||
128 | { 'k', &place_keywords_in_env }, | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | { 'm', &jobs_m_flag }, | - | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | { 'n', &read_but_dont_execute }, | - | ||||||||||||||||||||||||
133 | { 'p', &privileged_mode }, | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | { 'r', &restricted }, | - | ||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | { 't', &just_one_command }, | - | ||||||||||||||||||||||||
138 | { 'u', &unbound_vars_is_error }, | - | ||||||||||||||||||||||||
139 | { 'v', &verbose_flag }, | - | ||||||||||||||||||||||||
140 | { 'x', &echo_command_at_execute }, | - | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | { 'B', &brace_expansion }, | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | { 'C', &noclobber }, | - | ||||||||||||||||||||||||
150 | { 'E', &error_trace_mode }, | - | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | { 'H', &histexp_flag }, | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | { 'I', &no_invisible_vars }, | - | ||||||||||||||||||||||||
155 | { 'P', &no_symbolic_links }, | - | ||||||||||||||||||||||||
156 | { 'T', &function_trace_mode }, | - | ||||||||||||||||||||||||
157 | {0, (int *) | - | ||||||||||||||||||||||||
158 | ((void *)0) | - | ||||||||||||||||||||||||
159 | } | - | ||||||||||||||||||||||||
160 | }; | - | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | char optflags[(sizeof (shell_flags) / sizeof (struct flags_alist))+4] = { '+' }; | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | int * | - | ||||||||||||||||||||||||
167 | find_flag (name) | - | ||||||||||||||||||||||||
168 | int name; | - | ||||||||||||||||||||||||
169 | { | - | ||||||||||||||||||||||||
170 | int i; | - | ||||||||||||||||||||||||
171 | for (i = 0; shell_flags[i].name
| 0-2238050 | ||||||||||||||||||||||||
172 | { | - | ||||||||||||||||||||||||
173 | if (shell_flags[i].name == name
| 199955-2038095 | ||||||||||||||||||||||||
174 | return executed 199955 times by 1 test: (shell_flags[i].value);return (shell_flags[i].value); Executed by:
executed 199955 times by 1 test: return (shell_flags[i].value); Executed by:
| 199955 | ||||||||||||||||||||||||
175 | } executed 2038095 times by 1 test: end of block Executed by:
| 2038095 | ||||||||||||||||||||||||
176 | return never executed: ((int *)0);return ((int *)0); never executed: return ((int *)0); | 0 | ||||||||||||||||||||||||
177 | } | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | int | - | ||||||||||||||||||||||||
183 | change_flag (flag, on_or_off) | - | ||||||||||||||||||||||||
184 | int flag; | - | ||||||||||||||||||||||||
185 | int on_or_off; | - | ||||||||||||||||||||||||
186 | { | - | ||||||||||||||||||||||||
187 | int *value, old_value; | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||
191 | if (restricted
| 0-13715 | ||||||||||||||||||||||||
192 | return executed 1 time by 1 test: (-1);return (-1); Executed by:
executed 1 time by 1 test: return (-1); Executed by:
| 1 | ||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | value = find_flag (flag); | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | if ((
| 0-13715 | ||||||||||||||||||||||||
198 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | old_value = *value; | - | ||||||||||||||||||||||||
201 | *value = (
| 752-12963 | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | switch (flag) | - | ||||||||||||||||||||||||
205 | { | - | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | case executed 30 times by 1 test: 'H':case 'H': Executed by:
executed 30 times by 1 test: case 'H': Executed by:
| 30 | ||||||||||||||||||||||||
208 | history_expansion = histexp_flag; | - | ||||||||||||||||||||||||
209 | if (on_or_off == '-'
| 0-30 | ||||||||||||||||||||||||
210 | bash_initialize_history (); executed 30 times by 1 test: bash_initialize_history (); Executed by:
| 30 | ||||||||||||||||||||||||
211 | break; executed 30 times by 1 test: break; Executed by:
| 30 | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | case executed 5462 times by 1 test: 'm':case 'm': Executed by:
executed 5462 times by 1 test: case 'm': Executed by:
| 5462 | ||||||||||||||||||||||||
216 | set_job_control (on_or_off == '-'); | - | ||||||||||||||||||||||||
217 | break; executed 5462 times by 1 test: break; Executed by:
| 5462 | ||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | case executed 3347 times by 1 test: 'e':case 'e': Executed by:
executed 3347 times by 1 test: case 'e': Executed by:
| 3347 | ||||||||||||||||||||||||
221 | if (builtin_ignoring_errexit == 0
| 1-3346 | ||||||||||||||||||||||||
222 | exit_immediately_on_error = errexit_flag; executed 3346 times by 1 test: exit_immediately_on_error = errexit_flag; Executed by:
| 3346 | ||||||||||||||||||||||||
223 | break; executed 3347 times by 1 test: break; Executed by:
| 3347 | ||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||
225 | case executed 2 times by 1 test: 'n':case 'n': Executed by:
executed 2 times by 1 test: case 'n': Executed by:
| 2 | ||||||||||||||||||||||||
226 | if (interactive_shell
| 0-2 | ||||||||||||||||||||||||
227 | read_but_dont_execute = 0; never executed: read_but_dont_execute = 0; | 0 | ||||||||||||||||||||||||
228 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | case executed 11 times by 1 test: 'p':case 'p': Executed by:
executed 11 times by 1 test: case 'p': Executed by:
| 11 | ||||||||||||||||||||||||
231 | if (on_or_off == '+'
| 1-10 | ||||||||||||||||||||||||
232 | disable_priv_mode (); executed 10 times by 1 test: disable_priv_mode (); Executed by:
| 10 | ||||||||||||||||||||||||
233 | break; executed 11 times by 1 test: break; Executed by:
| 11 | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | case executed 1 time by 1 test: 'r':case 'r': Executed by:
executed 1 time by 1 test: case 'r': Executed by:
| 1 | ||||||||||||||||||||||||
237 | if (on_or_off == '-'
| 0-1 | ||||||||||||||||||||||||
238 | maybe_make_restricted (shell_name); executed 1 time by 1 test: maybe_make_restricted (shell_name); Executed by:
| 1 | ||||||||||||||||||||||||
239 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | case executed 4340 times by 1 test: 'v':case 'v': Executed by:
executed 4340 times by 1 test: case 'v': Executed by:
| 4340 | ||||||||||||||||||||||||
243 | echo_input_at_read = verbose_flag; | - | ||||||||||||||||||||||||
244 | break; executed 4340 times by 1 test: break; Executed by:
| 4340 | ||||||||||||||||||||||||
245 | } | - | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | return executed 13715 times by 1 test: (old_value);return (old_value); Executed by:
executed 13715 times by 1 test: return (old_value); Executed by:
| 13715 | ||||||||||||||||||||||||
248 | } | - | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | char * | - | ||||||||||||||||||||||||
253 | which_set_flags () | - | ||||||||||||||||||||||||
254 | { | - | ||||||||||||||||||||||||
255 | char *temp; | - | ||||||||||||||||||||||||
256 | int i, string_index; | - | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | temp = (char *)sh_xmalloc((1 + (sizeof (shell_flags) / sizeof (struct flags_alist)) + read_from_stdin + want_pending_command), "flags.c", 306); | - | ||||||||||||||||||||||||
259 | for (i = string_index = 0; shell_flags[i].name
| 76-1672 | ||||||||||||||||||||||||
260 | if (*(
| 161-1511 | ||||||||||||||||||||||||
261 | temp[string_index++] = shell_flags[i].name; executed 161 times by 1 test: temp[string_index++] = shell_flags[i].name; Executed by:
| 161 | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | if (want_pending_command
| 0-76 | ||||||||||||||||||||||||
264 | temp[string_index++] = 'c'; never executed: temp[string_index++] = 'c'; | 0 | ||||||||||||||||||||||||
265 | if (read_from_stdin
| 0-76 | ||||||||||||||||||||||||
266 | temp[string_index++] = 's'; never executed: temp[string_index++] = 's'; | 0 | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | temp[string_index] = '\0'; | - | ||||||||||||||||||||||||
269 | return executed 76 times by 1 test: (temp);return (temp); Executed by:
executed 76 times by 1 test: return (temp); Executed by:
| 76 | ||||||||||||||||||||||||
270 | } | - | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | char * | - | ||||||||||||||||||||||||
273 | get_current_flags () | - | ||||||||||||||||||||||||
274 | { | - | ||||||||||||||||||||||||
275 | char *temp; | - | ||||||||||||||||||||||||
276 | int i; | - | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | temp = (char *)sh_xmalloc((1 + (sizeof (shell_flags) / sizeof (struct flags_alist))), "flags.c", 326); | - | ||||||||||||||||||||||||
279 | for (i = 0; shell_flags[i].name
| 0 | ||||||||||||||||||||||||
280 | temp[i] = *(shell_flags[i].value); never executed: temp[i] = *(shell_flags[i].value); | 0 | ||||||||||||||||||||||||
281 | temp[i] = '\0'; | - | ||||||||||||||||||||||||
282 | return never executed: (temp);return (temp); never executed: return (temp); | 0 | ||||||||||||||||||||||||
283 | } | - | ||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | void | - | ||||||||||||||||||||||||
286 | set_current_flags (bitmap) | - | ||||||||||||||||||||||||
287 | const char *bitmap; | - | ||||||||||||||||||||||||
288 | { | - | ||||||||||||||||||||||||
289 | int i; | - | ||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||
291 | if (bitmap == 0
| 0 | ||||||||||||||||||||||||
292 | return; never executed: return; | 0 | ||||||||||||||||||||||||
293 | for (i = 0; shell_flags[i].name
| 0 | ||||||||||||||||||||||||
294 | *( never executed: shell_flags[i].value) = bitmap[i];*(shell_flags[i].value) = bitmap[i]; never executed: *(shell_flags[i].value) = bitmap[i]; | 0 | ||||||||||||||||||||||||
295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | void | - | ||||||||||||||||||||||||
298 | reset_shell_flags () | - | ||||||||||||||||||||||||
299 | { | - | ||||||||||||||||||||||||
300 | mark_modified_vars = disallow_filename_globbing = 0; | - | ||||||||||||||||||||||||
301 | place_keywords_in_env = read_but_dont_execute = just_one_command = 0; | - | ||||||||||||||||||||||||
302 | noclobber = unbound_vars_is_error = 0; | - | ||||||||||||||||||||||||
303 | echo_command_at_execute = jobs_m_flag = forced_interactive = 0; | - | ||||||||||||||||||||||||
304 | no_symbolic_links = no_invisible_vars = 0; | - | ||||||||||||||||||||||||
305 | privileged_mode = pipefail_opt = 0; | - | ||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||
307 | error_trace_mode = function_trace_mode = 0; | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | exit_immediately_on_error = errexit_flag = 0; | - | ||||||||||||||||||||||||
310 | echo_input_at_read = verbose_flag = 0; | - | ||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||
312 | hashing_enabled = interactive_comments = 1; | - | ||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||
315 | asynchronous_notification = 0; | - | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||
321 | - | |||||||||||||||||||||||||
322 | history_expansion = 1; | - | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | brace_expansion = 1; | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | restricted = 0; | - | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||
334 | - | |||||||||||||||||||||||||
335 | void | - | ||||||||||||||||||||||||
336 | initialize_flags () | - | ||||||||||||||||||||||||
337 | { | - | ||||||||||||||||||||||||
338 | register int i; | - | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | for (i = 0; shell_flags[i].name
| 5447-119834 | ||||||||||||||||||||||||
341 | optflags[i+1] = shell_flags[i].name; executed 119834 times by 1 test: optflags[i+1] = shell_flags[i].name; Executed by:
| 119834 | ||||||||||||||||||||||||
342 | optflags[++i] = 'o'; | - | ||||||||||||||||||||||||
343 | optflags[++i] = ';'; | - | ||||||||||||||||||||||||
344 | optflags[i+1] = '\0'; | - | ||||||||||||||||||||||||
345 | } executed 5447 times by 1 test: end of block Executed by:
| 5447 | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |