Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/exec.def |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | - | |||||||||||||||||||
16 | - | |||||||||||||||||||
17 | - | |||||||||||||||||||
18 | extern REDIRECT *redirection_undo_list; | - | ||||||||||||||||||
19 | extern char *exec_argv0; | - | ||||||||||||||||||
20 | - | |||||||||||||||||||
21 | int no_exit_on_failed_exec; | - | ||||||||||||||||||
22 | - | |||||||||||||||||||
23 | - | |||||||||||||||||||
24 | - | |||||||||||||||||||
25 | static char * | - | ||||||||||||||||||
26 | mkdashname (name) | - | ||||||||||||||||||
27 | char *name; | - | ||||||||||||||||||
28 | { | - | ||||||||||||||||||
29 | char *ret; | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | ret = (char *)sh_xmalloc((2 + strlen (name)), "./exec.def", 90); | - | ||||||||||||||||||
32 | ret[0] = '-'; | - | ||||||||||||||||||
33 | strcpy (ret + 1, name); | - | ||||||||||||||||||
34 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
35 | } | - | ||||||||||||||||||
36 | - | |||||||||||||||||||
37 | int | - | ||||||||||||||||||
38 | exec_builtin (list) | - | ||||||||||||||||||
39 | WORD_LIST *list; | - | ||||||||||||||||||
40 | { | - | ||||||||||||||||||
41 | int exit_value = 1; | - | ||||||||||||||||||
42 | int cleanenv, login, opt; | - | ||||||||||||||||||
43 | char *argv0, *command, **args, **env, *newname, *com2; | - | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | cleanenv = login = 0; | - | ||||||||||||||||||
46 | exec_argv0 = argv0 = (char *) | - | ||||||||||||||||||
47 | ((void *)0) | - | ||||||||||||||||||
48 | ; | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | reset_internal_getopt (); | - | ||||||||||||||||||
51 | while ((
| 5-262 | ||||||||||||||||||
52 | { | - | ||||||||||||||||||
53 | switch (opt) | - | ||||||||||||||||||
54 | { | - | ||||||||||||||||||
55 | case never executed: 'c':case 'c': never executed: case 'c': | 0 | ||||||||||||||||||
56 | cleanenv = 1; | - | ||||||||||||||||||
57 | break; never executed: break; | 0 | ||||||||||||||||||
58 | case never executed: 'l':case 'l': never executed: case 'l': | 0 | ||||||||||||||||||
59 | login = 1; | - | ||||||||||||||||||
60 | break; never executed: break; | 0 | ||||||||||||||||||
61 | case never executed: 'a':case 'a': never executed: case 'a': | 0 | ||||||||||||||||||
62 | argv0 = list_optarg; | - | ||||||||||||||||||
63 | break; never executed: break; | 0 | ||||||||||||||||||
64 | case never executed: -99:case -99: never executed: builtin_help (); returncase -99: never executed: (258);return (258); never executed: return (258); | 0 | ||||||||||||||||||
65 | default executed 5 times by 1 test: :default: Executed by:
executed 5 times by 1 test: default: Executed by:
| 5 | ||||||||||||||||||
66 | builtin_usage (); | - | ||||||||||||||||||
67 | return executed 5 times by 1 test: (258);return (258); Executed by:
executed 5 times by 1 test: return (258); Executed by:
| 5 | ||||||||||||||||||
68 | } | - | ||||||||||||||||||
69 | } | - | ||||||||||||||||||
70 | list = loptend; | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | - | |||||||||||||||||||
73 | dispose_redirects (redirection_undo_list); | - | ||||||||||||||||||
74 | redirection_undo_list = (REDIRECT *) | - | ||||||||||||||||||
75 | ((void *)0) | - | ||||||||||||||||||
76 | ; | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | if (list == 0
| 3-259 | ||||||||||||||||||
79 | return executed 259 times by 1 test: (0);return (0); Executed by:
executed 259 times by 1 test: return (0); Executed by:
| 259 | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | - | |||||||||||||||||||
82 | if (restricted
| 1-2 | ||||||||||||||||||
83 | { | - | ||||||||||||||||||
84 | sh_restricted ((char *) | - | ||||||||||||||||||
85 | ((void *)0) | - | ||||||||||||||||||
86 | ); | - | ||||||||||||||||||
87 | return executed 1 time by 1 test: (1);return (1); Executed by:
executed 1 time by 1 test: return (1); Executed by:
| 1 | ||||||||||||||||||
88 | } | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | - | |||||||||||||||||||
91 | args = strvec_from_word_list (list, 1, 0, (int *) | - | ||||||||||||||||||
92 | ((void *)0) | - | ||||||||||||||||||
93 | ); | - | ||||||||||||||||||
94 | env = (char **)0; | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | - | |||||||||||||||||||
97 | command = absolute_program (args[0])
| 0-2 | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | if (command == 0
| 0-2 | ||||||||||||||||||
100 | { | - | ||||||||||||||||||
101 | if (file_isdir (args[0])
| 0 | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | - | |||||||||||||||||||
104 | builtin_error ( | - | ||||||||||||||||||
105 | dcgettext (((void *)0), | - | ||||||||||||||||||
106 | "%s: cannot execute: %s" | - | ||||||||||||||||||
107 | , 5) | - | ||||||||||||||||||
108 | , args[0], strerror ( | - | ||||||||||||||||||
109 | 21 | - | ||||||||||||||||||
110 | )); | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | - | |||||||||||||||||||
113 | - | |||||||||||||||||||
114 | exit_value = 126; | - | ||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||
116 | else | - | ||||||||||||||||||
117 | { | - | ||||||||||||||||||
118 | sh_notfound (args[0]); | - | ||||||||||||||||||
119 | exit_value = 127; | - | ||||||||||||||||||
120 | } never executed: end of block | 0 | ||||||||||||||||||
121 | goto never executed: failed_exec;goto failed_exec; never executed: goto failed_exec; | 0 | ||||||||||||||||||
122 | } | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | com2 = full_pathname (command); | - | ||||||||||||||||||
125 | if (com2
| 0-2 | ||||||||||||||||||
126 | { | - | ||||||||||||||||||
127 | if (command != args[0]
| 0-2 | ||||||||||||||||||
128 | sh_xfree((command), "./exec.def", 173); never executed: sh_xfree((command), "./exec.def", 173); | 0 | ||||||||||||||||||
129 | command = com2; | - | ||||||||||||||||||
130 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | if (argv0
| 0-2 | ||||||||||||||||||
133 | { | - | ||||||||||||||||||
134 | sh_xfree((args[0]), "./exec.def", 179); | - | ||||||||||||||||||
135 | args[0] = login
| 0 | ||||||||||||||||||
136 | exec_argv0 = (char *)strcpy (sh_xmalloc((1 + strlen (args[0])), "./exec.def", 181), (args[0])); | - | ||||||||||||||||||
137 | } never executed: end of block | 0 | ||||||||||||||||||
138 | else if (login
| 0-2 | ||||||||||||||||||
139 | { | - | ||||||||||||||||||
140 | newname = mkdashname (args[0]); | - | ||||||||||||||||||
141 | sh_xfree((args[0]), "./exec.def", 186); | - | ||||||||||||||||||
142 | args[0] = newname; | - | ||||||||||||||||||
143 | } never executed: end of block | 0 | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | - | |||||||||||||||||||
146 | - | |||||||||||||||||||
147 | - | |||||||||||||||||||
148 | - | |||||||||||||||||||
149 | - | |||||||||||||||||||
150 | - | |||||||||||||||||||
151 | if (cleanenv == 0
| 0-2 | ||||||||||||||||||
152 | adjust_shell_level (-1); executed 1 time by 1 test: adjust_shell_level (-1); Executed by:
| 1 | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | if (cleanenv
| 0-2 | ||||||||||||||||||
155 | { | - | ||||||||||||||||||
156 | env = strvec_create (1); | - | ||||||||||||||||||
157 | env[0] = (char *)0; | - | ||||||||||||||||||
158 | } never executed: end of block | 0 | ||||||||||||||||||
159 | else | - | ||||||||||||||||||
160 | { | - | ||||||||||||||||||
161 | maybe_make_export_env (); | - | ||||||||||||||||||
162 | env = export_env; | - | ||||||||||||||||||
163 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | - | |||||||||||||||||||
166 | if (interactive_shell
| 0-2 | ||||||||||||||||||
167 | maybe_save_shell_history (); never executed: maybe_save_shell_history (); | 0 | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | - | |||||||||||||||||||
170 | restore_original_signals (); | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | - | |||||||||||||||||||
173 | if (subshell_environment == 0
| 1 | ||||||||||||||||||
174 | end_job_control (); executed 1 time by 1 test: end_job_control (); Executed by:
| 1 | ||||||||||||||||||
175 | if (interactive
| 0-2 | ||||||||||||||||||
176 | default_tty_job_signals (); never executed: default_tty_job_signals (); | 0 | ||||||||||||||||||
177 | - | |||||||||||||||||||
178 | - | |||||||||||||||||||
179 | exit_value = shell_execve (command, args, env); | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | - | |||||||||||||||||||
182 | - | |||||||||||||||||||
183 | - | |||||||||||||||||||
184 | args = (char **) | - | ||||||||||||||||||
185 | ((void *)0) | - | ||||||||||||||||||
186 | ; | - | ||||||||||||||||||
187 | if (cleanenv == 0
| 0-2 | ||||||||||||||||||
188 | adjust_shell_level (1); executed 2 times by 1 test: adjust_shell_level (1); Executed by:
| 2 | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | if (exit_value == 127
| 0-2 | ||||||||||||||||||
191 | goto executed 2 times by 1 test: failed_exec;goto failed_exec; Executed by:
executed 2 times by 1 test: goto failed_exec; Executed by:
| 2 | ||||||||||||||||||
192 | else if (executable_file (command) == 0
| 0 | ||||||||||||||||||
193 | { | - | ||||||||||||||||||
194 | builtin_error ( | - | ||||||||||||||||||
195 | dcgettext (((void *)0), | - | ||||||||||||||||||
196 | "%s: cannot execute: %s" | - | ||||||||||||||||||
197 | , 5) | - | ||||||||||||||||||
198 | , command, strerror ( | - | ||||||||||||||||||
199 | (*__errno_location ()) | - | ||||||||||||||||||
200 | )); | - | ||||||||||||||||||
201 | exit_value = 126; | - | ||||||||||||||||||
202 | } never executed: end of block | 0 | ||||||||||||||||||
203 | else | - | ||||||||||||||||||
204 | file_error (command); never executed: file_error (command); | 0 | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | failed_exec: code before this statement never executed: failed_exec: | 0 | ||||||||||||||||||
207 | do { if (command
executed 2 times by 1 test: } while (0);sh_xfree((command), "./exec.def", 244); Executed by:
| 0-2 | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | if (subshell_environment
| 0-1 | ||||||||||||||||||
210 | exit_shell (exit_value); executed 1 time by 1 test: exit_shell (exit_value); Executed by:
| 1 | ||||||||||||||||||
211 | - | |||||||||||||||||||
212 | if (args
| 0-1 | ||||||||||||||||||
213 | strvec_dispose (args); never executed: strvec_dispose (args); | 0 | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | if (env
| 0-1 | ||||||||||||||||||
216 | strvec_dispose (env); never executed: strvec_dispose (env); | 0 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | initialize_traps (); | - | ||||||||||||||||||
219 | initialize_signals (1); | - | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | - | |||||||||||||||||||
222 | if (interactive_shell
| 0-1 | ||||||||||||||||||
223 | restart_job_control (); never executed: restart_job_control (); | 0 | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | - | |||||||||||||||||||
226 | return executed 1 time by 1 test: (exit_value);return (exit_value); Executed by:
executed 1 time by 1 test: return (exit_value); Executed by:
| 1 | ||||||||||||||||||
227 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |