Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | static char *_find_user_command_internal (const char *, int); | - |
18 | static char *find_user_command_internal (const char *, int); | - |
19 | static char *find_user_command_in_path (const char *, char *, int); | - |
20 | static char *find_in_path_element (const char *, char *, int, int, struct stat *); | - |
21 | static char *find_absolute_program (const char *, int); | - |
22 | | - |
23 | static char *get_next_path_element (char *, int *); | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | static char *file_to_lose_on; | - |
31 | | - |
32 | | - |
33 | | - |
34 | int check_hashed_filenames = 0; | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | int dot_found_in_search = 0; | - |
41 | | - |
42 | | - |
43 | | - |
44 | static struct ignorevar execignore = | - |
45 | { | - |
46 | "EXECIGNORE", | - |
47 | | - |
48 | ((void *)0) | - |
49 | , | - |
50 | 0, | - |
51 | | - |
52 | ((void *)0) | - |
53 | , | - |
54 | | - |
55 | ((void *)0) | - |
56 | | - |
57 | }; | - |
58 | | - |
59 | void | - |
60 | setup_exec_ignore (varname) | - |
61 | char *varname; | - |
62 | { | - |
63 | setup_ignore_patterns (&execignore); | - |
64 | } never executed: end of block | 0 |
65 | | - |
66 | static int | - |
67 | exec_name_should_ignore (name) | - |
68 | const char *name; | - |
69 | { | - |
70 | struct ign *p; | - |
71 | | - |
72 | for (p = execignore.ignores; pTRUE | never evaluated | FALSE | evaluated 15553 times by 1 test |
&& p->valTRUE | never evaluated | FALSE | never evaluated |
; p++) | 0-15553 |
73 | if (strmatch (p->val, (char *)name, (extended_glob ? (1 << 5) : 0)|(1 << 4)) != 1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
74 | return never executed: return 1; 1;never executed: return 1; | 0 |
75 | returnexecuted 15553 times by 1 test: return 0; 0;executed 15553 times by 1 test: return 0; | 15553 |
76 | } | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | int | - |
83 | file_status (name) | - |
84 | const char *name; | - |
85 | { | - |
86 | struct stat finfo; | - |
87 | int r; | - |
88 | | - |
89 | | - |
90 | if (stat (name, &finfo) < 0TRUE | evaluated 42002 times by 1 test | FALSE | evaluated 15553 times by 1 test |
) | 15553-42002 |
91 | returnexecuted 42002 times by 1 test: return (0); (0);executed 42002 times by 1 test: return (0); | 42002 |
92 | | - |
93 | | - |
94 | | - |
95 | if ( | - |
96 | ((((TRUE | never evaluated | FALSE | evaluated 15553 times by 1 test |
| 0-15553 |
97 | finfo.st_modeTRUE | never evaluated | FALSE | evaluated 15553 times by 1 test |
| 0-15553 |
98 | )) & 0170000) == (0040000))TRUE | never evaluated | FALSE | evaluated 15553 times by 1 test |
| 0-15553 |
99 | ) | - |
100 | return never executed: return (0x1|0x10); (0x1|0x10);never executed: return (0x1|0x10); | 0 |
101 | | - |
102 | r = 0x1; | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | if (exec_name_should_ignore (name) == 0TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
&& eaccess (name, TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
| 0-15553 |
110 | 1TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
| 0-15553 |
111 | ) == 0TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
) | 0-15553 |
112 | r |= 0x2;executed 15553 times by 1 test: r |= 0x2; | 15553 |
113 | if (eaccess (name, TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
| 0-15553 |
114 | 4TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
| 0-15553 |
115 | ) == 0TRUE | evaluated 15553 times by 1 test | FALSE | never evaluated |
) | 0-15553 |
116 | r |= 0x40;executed 15553 times by 1 test: r |= 0x40; | 15553 |
117 | | - |
118 | returnexecuted 15553 times by 1 test: return r; r;executed 15553 times by 1 test: return r; | 15553 |
119 | } | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | int | - |
126 | executable_file (file) | - |
127 | const char *file; | - |
128 | { | - |
129 | int s; | - |
130 | | - |
131 | s = file_status (file); | - |
132 | | - |
133 | if (s & 0x10TRUE | never evaluated | FALSE | evaluated 21481 times by 1 test |
) | 0-21481 |
134 | | - |
135 | (* never executed: (*__errno_location ()) = 21 ; __errno_location ()) never executed: (*__errno_location ()) = 21 ; | 0 |
136 | = never executed: (*__errno_location ()) = 21 ; | 0 |
137 | 21 never executed: (*__errno_location ()) = 21 ; | 0 |
138 | ; never executed: (*__errno_location ()) = 21 ; | 0 |
139 | | - |
140 | returnexecuted 21481 times by 1 test: return ((s & 0x2) && ((s & 0x10) == 0)); ((s & 0x2) && ((s & 0x10) == 0));executed 21481 times by 1 test: return ((s & 0x2) && ((s & 0x10) == 0)); | 21481 |
141 | } | - |
142 | | - |
143 | int | - |
144 | is_directory (file) | - |
145 | const char *file; | - |
146 | { | - |
147 | returnexecuted 5309 times by 1 test: return (file_status (file) & 0x10); (file_status (file) & 0x10);executed 5309 times by 1 test: return (file_status (file) & 0x10); | 5309 |
148 | } | - |
149 | | - |
150 | int | - |
151 | executable_or_directory (file) | - |
152 | const char *file; | - |
153 | { | - |
154 | int s; | - |
155 | | - |
156 | s = file_status (file); | - |
157 | return never executed: return ((s & 0x2) || (s & 0x10)); ((s & 0x2) || (s & 0x10));never executed: return ((s & 0x2) || (s & 0x10)); | 0 |
158 | } | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | char * | - |
166 | find_user_command (name) | - |
167 | const char *name; | - |
168 | { | - |
169 | returnexecuted 49 times by 1 test: return (find_user_command_internal (name, 0x4|0x20)); (find_user_command_internal (name, 0x4|0x20));executed 49 times by 1 test: return (find_user_command_internal (name, 0x4|0x20)); | 49 |
170 | } | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | char * | - |
178 | find_path_file (name) | - |
179 | const char *name; | - |
180 | { | - |
181 | returnexecuted 1 time by 1 test: return (find_user_command_internal (name, 0x40)); (find_user_command_internal (name, 0x40));executed 1 time by 1 test: return (find_user_command_internal (name, 0x40)); | 1 |
182 | } | - |
183 | | - |
184 | static char * | - |
185 | _find_user_command_internal (name, flags) | - |
186 | const char *name; | - |
187 | int flags; | - |
188 | { | - |
189 | char *path_list, *cmd; | - |
190 | SHELL_VAR *var; | - |
191 | | - |
192 | | - |
193 | | - |
194 | if (var = find_variable_tempenv ("PATH")TRUE | evaluated 50 times by 1 test | FALSE | never evaluated |
) | 0-50 |
195 | path_list = ((var)->value);executed 50 times by 1 test: path_list = ((var)->value); | 50 |
196 | else | - |
197 | path_list = (char *) never executed: path_list = (char *) ((void *)0) ; | 0 |
198 | ((void *)0) never executed: path_list = (char *) ((void *)0) ; | 0 |
199 | ; never executed: path_list = (char *) ((void *)0) ; | 0 |
200 | | - |
201 | if (path_list == 0TRUE | never evaluated | FALSE | evaluated 50 times by 1 test |
|| *TRUE | evaluated 2 times by 1 test | FALSE | evaluated 48 times by 1 test |
path_list == '\0'TRUE | evaluated 2 times by 1 test | FALSE | evaluated 48 times by 1 test |
) | 0-50 |
202 | returnexecuted 2 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 275), (name))); ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 275), (name)));executed 2 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 275), (name))); | 2 |
203 | | - |
204 | cmd = find_user_command_in_path (name, path_list, flags); | - |
205 | | - |
206 | returnexecuted 48 times by 1 test: return (cmd); (cmd);executed 48 times by 1 test: return (cmd); | 48 |
207 | } | - |
208 | | - |
209 | static char * | - |
210 | find_user_command_internal (name, flags) | - |
211 | const char *name; | - |
212 | int flags; | - |
213 | { | - |
214 | returnexecuted 50 times by 1 test: return (_find_user_command_internal (name, flags)); (_find_user_command_internal (name, flags));executed 50 times by 1 test: return (_find_user_command_internal (name, flags)); | 50 |
215 | | - |
216 | } | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | static char * | - |
223 | get_next_path_element (path_list, path_index_pointer) | - |
224 | char *path_list; | - |
225 | int *path_index_pointer; | - |
226 | { | - |
227 | char *path; | - |
228 | | - |
229 | path = extract_colon_unit (path_list, path_index_pointer); | - |
230 | | - |
231 | if (path == 0TRUE | never evaluated | FALSE | evaluated 30723 times by 1 test |
) | 0-30723 |
232 | return never executed: return (path); (path);never executed: return (path); | 0 |
233 | | - |
234 | if (*TRUE | evaluated 12 times by 1 test | FALSE | evaluated 30711 times by 1 test |
path == '\0'TRUE | evaluated 12 times by 1 test | FALSE | evaluated 30711 times by 1 test |
) | 12-30711 |
235 | { | - |
236 | sh_xfree((path), "findcmd.c", 321); | - |
237 | path = (char *)strcpy (sh_xmalloc((1 + strlen (".")), "findcmd.c", 322), (".")); | - |
238 | }executed 12 times by 1 test: end of block | 12 |
239 | | - |
240 | returnexecuted 30723 times by 1 test: return (path); (path);executed 30723 times by 1 test: return (path); | 30723 |
241 | } | - |
242 | char * | - |
243 | search_for_command (pathname, flags) | - |
244 | const char *pathname; | - |
245 | int flags; | - |
246 | { | - |
247 | char *hashed_file, *command, *path_list; | - |
248 | int temp_path, st; | - |
249 | SHELL_VAR *path; | - |
250 | | - |
251 | hashed_file = command = (char *) | - |
252 | ((void *)0) | - |
253 | ; | - |
254 | | - |
255 | | - |
256 | | - |
257 | path = find_variable_tempenv ("PATH"); | - |
258 | temp_path = pathTRUE | evaluated 27738 times by 1 test | FALSE | evaluated 69 times by 1 test |
&& ((((TRUE | evaluated 1 time by 1 test | FALSE | evaluated 27737 times by 1 test |
path)->attributes) & (0x0100000)))TRUE | evaluated 1 time by 1 test | FALSE | evaluated 27737 times by 1 test |
; | 1-27738 |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | if (temp_path == 0TRUE | evaluated 27806 times by 1 test | FALSE | evaluated 1 time by 1 test |
&& absolute_program (pathname) == 0TRUE | evaluated 26821 times by 1 test | FALSE | evaluated 985 times by 1 test |
) | 1-27806 |
264 | hashed_file = phash_search (pathname);executed 26821 times by 1 test: hashed_file = phash_search (pathname); | 26821 |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | if (hashed_fileTRUE | evaluated 21477 times by 1 test | FALSE | evaluated 6330 times by 1 test |
&& (posixly_correctTRUE | evaluated 11 times by 1 test | FALSE | evaluated 21466 times by 1 test |
|| check_hashed_filenamesTRUE | never evaluated | FALSE | evaluated 21466 times by 1 test |
)) | 0-21477 |
271 | { | - |
272 | st = file_status (hashed_file); | - |
273 | if ((TRUE | never evaluated | FALSE | evaluated 11 times by 1 test |
st & (0x1|0x2)) != (0x1|0x2)TRUE | never evaluated | FALSE | evaluated 11 times by 1 test |
) | 0-11 |
274 | { | - |
275 | phash_remove (pathname); | - |
276 | sh_xfree((hashed_file), "findcmd.c", 367); | - |
277 | hashed_file = (char *) | - |
278 | ((void *)0) | - |
279 | ; | - |
280 | } never executed: end of block | 0 |
281 | }executed 11 times by 1 test: end of block | 11 |
282 | | - |
283 | if (hashed_fileTRUE | evaluated 21477 times by 1 test | FALSE | evaluated 6330 times by 1 test |
) | 6330-21477 |
284 | command = hashed_file;executed 21477 times by 1 test: command = hashed_file; | 21477 |
285 | else if (absolute_program (pathname)TRUE | evaluated 986 times by 1 test | FALSE | evaluated 5344 times by 1 test |
) | 986-5344 |
286 | | - |
287 | | - |
288 | command = (char *)strcpy (sh_xmalloc((1 + strlen (pathname)), "findcmd.c", 377), (pathname));executed 986 times by 1 test: command = (char *)strcpy (sh_xmalloc((1 + strlen (pathname)), "findcmd.c", 377), (pathname)); | 986 |
289 | else | - |
290 | { | - |
291 | if (flags & 0x02TRUE | evaluated 21 times by 1 test | FALSE | evaluated 5323 times by 1 test |
) | 21-5323 |
292 | path_list = conf_standard_path ();executed 21 times by 1 test: path_list = conf_standard_path (); | 21 |
293 | else if (temp_pathTRUE | never evaluated | FALSE | evaluated 5323 times by 1 test |
|| pathTRUE | evaluated 5323 times by 1 test | FALSE | never evaluated |
) | 0-5323 |
294 | path_list = ((path)->value);executed 5323 times by 1 test: path_list = ((path)->value); | 5323 |
295 | else | - |
296 | path_list = 0; never executed: path_list = 0; | 0 |
297 | | - |
298 | command = find_user_command_in_path (pathname, path_list, 0x4|0x20); | - |
299 | | - |
300 | if (commandTRUE | evaluated 5291 times by 1 test | FALSE | evaluated 53 times by 1 test |
&& hashing_enabledTRUE | evaluated 5291 times by 1 test | FALSE | never evaluated |
&& temp_path == 0TRUE | evaluated 5291 times by 1 test | FALSE | never evaluated |
&& (TRUE | evaluated 5291 times by 1 test | FALSE | never evaluated |
flags & 0x01)TRUE | evaluated 5291 times by 1 test | FALSE | never evaluated |
) | 0-5291 |
301 | { | - |
302 | | - |
303 | | - |
304 | | - |
305 | if (((TRUE | evaluated 17 times by 1 test | FALSE | evaluated 5274 times by 1 test |
command)[0] == (pathname)[0]TRUE | evaluated 17 times by 1 test | FALSE | evaluated 5274 times by 1 test |
&& | 17-5274 |
306 | __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
307 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
308 | ) && __builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
309 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
310 | ) && (__s1_len = __builtin_strlen (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
311 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
312 | ), __s2_len = __builtin_strlen (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
313 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
314 | ), (!((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
315 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
316 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
317 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
318 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
319 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
320 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
321 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
322 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
323 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
324 | , TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
325 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
326 | ) : (__builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
327 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
328 | ) && ((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
329 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
330 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
331 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
332 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
333 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
334 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
335 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
336 | ) && ((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
337 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
338 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
339 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
340 | ) == 1) ? __builtin_strcmp (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
341 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
342 | , TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
343 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
344 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
345 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
346 | ); int __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
347 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
348 | ))[0] - __s2[0]); if (__s1_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
349 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
350 | ))[1] - __s2[1]); if (__s1_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
351 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
352 | ))[2] - __s2[2]); if (__s1_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( command ))[3] - __s2[3]); TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
353 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( command ))[3] - __s2[3]); | 0-17 |
354 | ))[3] - __s2[3]);TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( command ))[3] - __s2[3]); }never executed: end of block }never executed: end of block __result; }))) : (__builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
355 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
356 | ) && ((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
357 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
358 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
359 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
360 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
361 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
362 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
363 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
364 | ) && ((size_t)(const void *)((TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
365 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
366 | ) + 1) - (size_t)(const void *)(TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
367 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
368 | ) == 1) ? __builtin_strcmp (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
369 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
370 | , TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
371 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
372 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
373 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
374 | ); int __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
375 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
376 | ))[0] - __s2[0]); if (__s2_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
377 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
378 | ))[1] - __s2[1]); if (__s2_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
379 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
380 | ))[2] - __s2[2]); if (__s2_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( pathname ))[3] - __s2[3]); TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
381 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( pathname ))[3] - __s2[3]); | 0-17 |
382 | ))[3] - __s2[3]);TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( pathname ))[3] - __s2[3]); }never executed: end of block }never executed: end of block __result; }))) : __builtin_strcmp (TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
383 | commandTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
384 | , TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
385 | pathnameTRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
386 | )))); }) TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
| 0-17 |
387 | == 0TRUE | evaluated 17 times by 1 test | FALSE | never evaluated |
)) | 0-17 |
388 | { | - |
389 | st = file_status (command); | - |
390 | if (st & 0x2TRUE | never evaluated | FALSE | evaluated 17 times by 1 test |
) | 0-17 |
391 | phash_insert ((char *)pathname, command, dot_found_in_search, 1); never executed: phash_insert ((char *)pathname, command, dot_found_in_search, 1); | 0 |
392 | }executed 17 times by 1 test: end of block | 17 |
393 | else | - |
394 | phash_insert ((char *)pathname, command, dot_found_in_search, 1);executed 5274 times by 1 test: phash_insert ((char *)pathname, command, dot_found_in_search, 1); | 5274 |
395 | } | - |
396 | | - |
397 | if (flags & 0x02TRUE | evaluated 21 times by 1 test | FALSE | evaluated 5323 times by 1 test |
) | 21-5323 |
398 | sh_xfree((path_list), "findcmd.c", 405);executed 21 times by 1 test: sh_xfree((path_list), "findcmd.c", 405); | 21 |
399 | }executed 5344 times by 1 test: end of block | 5344 |
400 | | - |
401 | returnexecuted 27807 times by 1 test: return (command); (command);executed 27807 times by 1 test: return (command); | 27807 |
402 | } | - |
403 | | - |
404 | char * | - |
405 | user_command_matches (name, flags, state) | - |
406 | const char *name; | - |
407 | int flags, state; | - |
408 | { | - |
409 | register int i; | - |
410 | int path_index, name_len; | - |
411 | char *path_list, *path_element, *match; | - |
412 | struct stat dotinfo; | - |
413 | static char **match_list = | - |
414 | ((void *)0) | - |
415 | ; | - |
416 | static int match_list_size = 0; | - |
417 | static int match_index = 0; | - |
418 | | - |
419 | if (state == 0TRUE | evaluated 2 times by 1 test | FALSE | never evaluated |
) | 0-2 |
420 | { | - |
421 | | - |
422 | if (match_list == 0TRUE | evaluated 2 times by 1 test | FALSE | never evaluated |
) | 0-2 |
423 | { | - |
424 | match_list_size = 5; | - |
425 | match_list = strvec_create (match_list_size); | - |
426 | }executed 2 times by 1 test: end of block | 2 |
427 | | - |
428 | | - |
429 | for (i = 0; i < match_list_sizeTRUE | evaluated 10 times by 1 test | FALSE | evaluated 2 times by 1 test |
; i++) | 2-10 |
430 | match_list[i] = 0;executed 10 times by 1 test: match_list[i] = 0; | 10 |
431 | | - |
432 | | - |
433 | match_index = 0; | - |
434 | | - |
435 | if (absolute_program (name)TRUE | never evaluated | FALSE | evaluated 2 times by 1 test |
) | 0-2 |
436 | { | - |
437 | match_list[0] = find_absolute_program (name, flags); | - |
438 | match_list[1] = (char *) | - |
439 | ((void *)0) | - |
440 | ; | - |
441 | path_list = (char *) | - |
442 | ((void *)0) | - |
443 | ; | - |
444 | } never executed: end of block | 0 |
445 | else | - |
446 | { | - |
447 | name_len = strlen (name); | - |
448 | file_to_lose_on = (char *) | - |
449 | ((void *)0) | - |
450 | ; | - |
451 | dot_found_in_search = 0; | - |
452 | if (stat (".", &dotinfo) < 0TRUE | never evaluated | FALSE | evaluated 2 times by 1 test |
) | 0-2 |
453 | dotinfo.st_dev = dotinfo.st_ino = 0; never executed: dotinfo.st_dev = dotinfo.st_ino = 0; | 0 |
454 | path_list = get_string_value ("PATH"); | - |
455 | path_index = 0; | - |
456 | }executed 2 times by 1 test: end of block | 2 |
457 | | - |
458 | while (path_listTRUE | evaluated 18 times by 1 test | FALSE | never evaluated |
&& path_list[path_index]TRUE | evaluated 16 times by 1 test | FALSE | evaluated 2 times by 1 test |
) | 0-18 |
459 | { | - |
460 | path_element = get_next_path_element (path_list, &path_index); | - |
461 | | - |
462 | if (path_element == 0TRUE | never evaluated | FALSE | evaluated 16 times by 1 test |
) | 0-16 |
463 | break; never executed: break; | 0 |
464 | | - |
465 | match = find_in_path_element (name, path_element, flags, name_len, &dotinfo); | - |
466 | | - |
467 | sh_xfree((path_element), "findcmd.c", 466); | - |
468 | | - |
469 | if (match == 0TRUE | evaluated 16 times by 1 test | FALSE | never evaluated |
) | 0-16 |
470 | continue;executed 16 times by 1 test: continue; | 16 |
471 | | - |
472 | if (match_index + 1 == match_list_sizeTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
473 | { | - |
474 | match_list_size += 10; | - |
475 | match_list = strvec_resize (match_list, (match_list_size + 1)); | - |
476 | } never executed: end of block | 0 |
477 | | - |
478 | match_list[match_index++] = match; | - |
479 | match_list[match_index] = (char *) | - |
480 | ((void *)0) | - |
481 | ; | - |
482 | do { if (file_to_lose_onTRUE | never evaluated | FALSE | never evaluated |
) sh_xfree((file_to_lose_on), "findcmd.c", 479);never executed: sh_xfree((file_to_lose_on), "findcmd.c", 479); } while (0); | 0 |
483 | file_to_lose_on = (char *) | - |
484 | ((void *)0) | - |
485 | ; | - |
486 | } never executed: end of block | 0 |
487 | | - |
488 | | - |
489 | match_index = 0; | - |
490 | }executed 2 times by 1 test: end of block | 2 |
491 | | - |
492 | match = match_list[match_index]; | - |
493 | | - |
494 | if (matchTRUE | never evaluated | FALSE | evaluated 2 times by 1 test |
) | 0-2 |
495 | match_index++; never executed: match_index++; | 0 |
496 | | - |
497 | returnexecuted 2 times by 1 test: return (match); (match);executed 2 times by 1 test: return (match); | 2 |
498 | } | - |
499 | | - |
500 | static char * | - |
501 | find_absolute_program (name, flags) | - |
502 | const char *name; | - |
503 | int flags; | - |
504 | { | - |
505 | int st; | - |
506 | | - |
507 | st = file_status (name); | - |
508 | | - |
509 | | - |
510 | if ((TRUE | never evaluated | FALSE | never evaluated |
st & 0x1) == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
511 | return never executed: return ((char *) ((void *)0) ); ((char *)never executed: return ((char *) ((void *)0) ); | 0 |
512 | ((void *)0) never executed: return ((char *) ((void *)0) ); | 0 |
513 | ); never executed: return ((char *) ((void *)0) ); | 0 |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & 0x1)TRUE | never evaluated | FALSE | never evaluated |
|| ((TRUE | never evaluated | FALSE | never evaluated |
flags & 0x8)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
st & 0x2)TRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
519 | return never executed: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 512), (name))); ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 512), (name)));never executed: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 512), (name))); | 0 |
520 | | - |
521 | return never executed: return ( ((void *)0) ); (never executed: return ( ((void *)0) ); | 0 |
522 | ((void *)0) never executed: return ( ((void *)0) ); | 0 |
523 | ); never executed: return ( ((void *)0) ); | 0 |
524 | } | - |
525 | | - |
526 | static char * | - |
527 | find_in_path_element (name, path, flags, name_len, dotinfop) | - |
528 | const char *name; | - |
529 | char *path; | - |
530 | int flags, name_len; | - |
531 | struct stat *dotinfop; | - |
532 | { | - |
533 | int status; | - |
534 | char *full_path, *xpath; | - |
535 | | - |
536 | xpath = (posixly_correct == 0TRUE | evaluated 30672 times by 1 test | FALSE | evaluated 51 times by 1 test |
&& *TRUE | never evaluated | FALSE | evaluated 30672 times by 1 test |
path == '~'TRUE | never evaluated | FALSE | evaluated 30672 times by 1 test |
) ? bash_tilde_expand (path, 0) : path; | 0-30672 |
537 | | - |
538 | | - |
539 | | - |
540 | if (dot_found_in_search == 0TRUE | evaluated 5767 times by 1 test | FALSE | evaluated 24956 times by 1 test |
&& *TRUE | evaluated 5255 times by 1 test | FALSE | evaluated 512 times by 1 test |
xpath == '.'TRUE | evaluated 5255 times by 1 test | FALSE | evaluated 512 times by 1 test |
) | 512-24956 |
541 | dot_found_in_search = same_file (".", xpath, dotinfop, (struct stat *)executed 5255 times by 1 test: dot_found_in_search = same_file (".", xpath, dotinfop, (struct stat *) ((void *)0) ); | 5255 |
542 | ((void *)0)executed 5255 times by 1 test: dot_found_in_search = same_file (".", xpath, dotinfop, (struct stat *) ((void *)0) ); | 5255 |
543 | );executed 5255 times by 1 test: dot_found_in_search = same_file (".", xpath, dotinfop, (struct stat *) ((void *)0) ); | 5255 |
544 | | - |
545 | full_path = sh_makepath (xpath, name, 0); | - |
546 | | - |
547 | status = file_status (full_path); | - |
548 | | - |
549 | if (xpath != pathTRUE | never evaluated | FALSE | evaluated 30723 times by 1 test |
) | 0-30723 |
550 | sh_xfree((xpath), "findcmd.c", 539); never executed: sh_xfree((xpath), "findcmd.c", 539); | 0 |
551 | | - |
552 | if ((TRUE | evaluated 25420 times by 1 test | FALSE | evaluated 5303 times by 1 test |
status & 0x1) == 0TRUE | evaluated 25420 times by 1 test | FALSE | evaluated 5303 times by 1 test |
) | 5303-25420 |
553 | { | - |
554 | sh_xfree((full_path), "findcmd.c", 543); | - |
555 | returnexecuted 25420 times by 1 test: return ((char *) ((void *)0) ); ((char *)executed 25420 times by 1 test: return ((char *) ((void *)0) ); | 25420 |
556 | ((void *)0)executed 25420 times by 1 test: return ((char *) ((void *)0) ); | 25420 |
557 | );executed 25420 times by 1 test: return ((char *) ((void *)0) ); | 25420 |
558 | } | - |
559 | | - |
560 | | - |
561 | if (flags & 0x1TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
) | 0-5303 |
562 | return never executed: return (full_path); (full_path);never executed: return (full_path); | 0 |
563 | | - |
564 | | - |
565 | | - |
566 | if ((TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
flags & 0x40)TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
&& (TRUE | never evaluated | FALSE | never evaluated |
status & 0x40)TRUE | never evaluated | FALSE | never evaluated |
) | 0-5303 |
567 | return never executed: return (full_path); (full_path);never executed: return (full_path); | 0 |
568 | | - |
569 | | - |
570 | | - |
571 | if ((TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
status & 0x2)TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
&& (TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
flags & (0x8|0x4))TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
&& | 0-5303 |
572 | (((TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
flags & 0x20) == 0)TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
|| ((TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
status & 0x10) == 0)TRUE | evaluated 5303 times by 1 test | FALSE | never evaluated |
)) | 0-5303 |
573 | { | - |
574 | do { if (file_to_lose_onTRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
) sh_xfree((file_to_lose_on), "findcmd.c", 561);never executed: sh_xfree((file_to_lose_on), "findcmd.c", 561); } while (0); | 0-5303 |
575 | file_to_lose_on = (char *) | - |
576 | ((void *)0) | - |
577 | ; | - |
578 | returnexecuted 5303 times by 1 test: return (full_path); (full_path);executed 5303 times by 1 test: return (full_path); | 5303 |
579 | } | - |
580 | | - |
581 | | - |
582 | | - |
583 | | - |
584 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & 0x4)TRUE | never evaluated | FALSE | never evaluated |
&& file_to_lose_on == 0TRUE | never evaluated | FALSE | never evaluated |
&& exec_name_should_ignore (full_path) == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
585 | file_to_lose_on = (char *)strcpy (sh_xmalloc((1 + strlen (full_path)), "findcmd.c", 570), (full_path)); never executed: file_to_lose_on = (char *)strcpy (sh_xmalloc((1 + strlen (full_path)), "findcmd.c", 570), (full_path)); | 0 |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & (0x8|0x4))TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
591 | ((TRUE | never evaluated | FALSE | never evaluated |
flags & 0x20)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
status & 0x10)TRUE | never evaluated | FALSE | never evaluated |
) || | 0 |
592 | ((TRUE | never evaluated | FALSE | never evaluated |
flags & 0x40)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
status & 0x40) == 0TRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
593 | { | - |
594 | sh_xfree((full_path), "findcmd.c", 579); | - |
595 | return never executed: return ((char *) ((void *)0) ); ((char *)never executed: return ((char *) ((void *)0) ); | 0 |
596 | ((void *)0) never executed: return ((char *) ((void *)0) ); | 0 |
597 | ); never executed: return ((char *) ((void *)0) ); | 0 |
598 | } | - |
599 | else | - |
600 | return never executed: return (full_path); (full_path);never executed: return (full_path); | 0 |
601 | } | - |
602 | static char * | - |
603 | find_user_command_in_path (name, path_list, flags) | - |
604 | const char *name; | - |
605 | char *path_list; | - |
606 | int flags; | - |
607 | { | - |
608 | char *full_path, *path; | - |
609 | int path_index, name_len; | - |
610 | struct stat dotinfo; | - |
611 | | - |
612 | | - |
613 | | - |
614 | dot_found_in_search = 0; | - |
615 | | - |
616 | if (absolute_program (name)TRUE | never evaluated | FALSE | evaluated 5398 times by 1 test |
) | 0-5398 |
617 | { | - |
618 | full_path = find_absolute_program (name, flags); | - |
619 | return never executed: return (full_path); (full_path);never executed: return (full_path); | 0 |
620 | } | - |
621 | | - |
622 | if (path_list == 0TRUE | never evaluated | FALSE | evaluated 5398 times by 1 test |
|| *TRUE | evaluated 17 times by 1 test | FALSE | evaluated 5381 times by 1 test |
path_list == '\0'TRUE | evaluated 17 times by 1 test | FALSE | evaluated 5381 times by 1 test |
) | 0-5398 |
623 | returnexecuted 17 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 619), (name))); ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 619), (name)));executed 17 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (name)), "findcmd.c", 619), (name))); | 17 |
624 | | - |
625 | file_to_lose_on = (char *) | - |
626 | ((void *)0) | - |
627 | ; | - |
628 | name_len = strlen (name); | - |
629 | if (stat (".", &dotinfo) < 0TRUE | never evaluated | FALSE | evaluated 5381 times by 1 test |
) | 0-5381 |
630 | dotinfo.st_dev = dotinfo.st_ino = 0; never executed: dotinfo.st_dev = dotinfo.st_ino = 0; | 0 |
631 | path_index = 0; | - |
632 | | - |
633 | while (path_list[path_index]TRUE | evaluated 30707 times by 1 test | FALSE | evaluated 78 times by 1 test |
) | 78-30707 |
634 | { | - |
635 | | - |
636 | do { if (terminating_signalTRUE | never evaluated | FALSE | evaluated 30707 times by 1 test |
) termsig_handler (terminating_signal);never executed: termsig_handler (terminating_signal); if (interrupt_stateTRUE | never evaluated | FALSE | evaluated 30707 times by 1 test |
) throw_to_top_level ();never executed: throw_to_top_level (); } while (0); | 0-30707 |
637 | | - |
638 | path = get_next_path_element (path_list, &path_index); | - |
639 | if (path == 0TRUE | never evaluated | FALSE | evaluated 30707 times by 1 test |
) | 0-30707 |
640 | break; never executed: break; | 0 |
641 | | - |
642 | | - |
643 | | - |
644 | full_path = find_in_path_element (name, path, flags, name_len, &dotinfo); | - |
645 | sh_xfree((path), "findcmd.c", 639); | - |
646 | | - |
647 | | - |
648 | | - |
649 | if (full_pathTRUE | evaluated 5303 times by 1 test | FALSE | evaluated 25404 times by 1 test |
&& is_directory (full_path)TRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
) | 0-25404 |
650 | { | - |
651 | sh_xfree((full_path), "findcmd.c", 645); | - |
652 | continue; never executed: continue; | 0 |
653 | } | - |
654 | | - |
655 | if (full_pathTRUE | evaluated 5303 times by 1 test | FALSE | evaluated 25404 times by 1 test |
) | 5303-25404 |
656 | { | - |
657 | do { if (file_to_lose_onTRUE | never evaluated | FALSE | evaluated 5303 times by 1 test |
) sh_xfree((file_to_lose_on), "findcmd.c", 651);never executed: sh_xfree((file_to_lose_on), "findcmd.c", 651); } while (0); | 0-5303 |
658 | returnexecuted 5303 times by 1 test: return (full_path); (full_path);executed 5303 times by 1 test: return (full_path); | 5303 |
659 | } | - |
660 | }executed 25404 times by 1 test: end of block | 25404 |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | if (file_to_lose_onTRUE | never evaluated | FALSE | evaluated 78 times by 1 test |
&& (TRUE | never evaluated | FALSE | never evaluated |
flags & 0x20)TRUE | never evaluated | FALSE | never evaluated |
&& is_directory (file_to_lose_on)TRUE | never evaluated | FALSE | never evaluated |
) | 0-78 |
669 | { | - |
670 | sh_xfree((file_to_lose_on), "findcmd.c", 664); | - |
671 | file_to_lose_on = (char *) | - |
672 | ((void *)0) | - |
673 | ; | - |
674 | } never executed: end of block | 0 |
675 | | - |
676 | returnexecuted 78 times by 1 test: return (file_to_lose_on); (file_to_lose_on);executed 78 times by 1 test: return (file_to_lose_on); | 78 |
677 | } | - |
678 | | - |
679 | | - |
680 | | - |
681 | char * | - |
682 | find_in_path (name, path_list, flags) | - |
683 | const char *name; | - |
684 | char *path_list; | - |
685 | int flags; | - |
686 | { | - |
687 | returnexecuted 6 times by 1 test: return (find_user_command_in_path (name, path_list, flags)); (find_user_command_in_path (name, path_list, flags));executed 6 times by 1 test: return (find_user_command_in_path (name, path_list, flags)); | 6 |
688 | } | - |
| | |