OpenCoverage

exec.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/exec.def
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18extern REDIRECT *redirection_undo_list;-
19extern char *exec_argv0;-
20-
21int no_exit_on_failed_exec;-
22-
23-
24-
25static char *-
26mkdashname (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: return ret;
ret;
never executed: return ret;
0
35}-
36-
37int-
38exec_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 ((
(opt = interna..."cla:")) != -1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 262 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "cla:")) != -1
(opt = interna..."cla:")) != -1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 262 times by 1 test
Evaluated by:
  • Self test
)
5-262
52 {-
53 switch (opt)-
54 {-
55 case
never executed: case 'c':
'c':
never executed: case 'c':
0
56 cleanenv = 1;-
57 break;
never executed: break;
0
58 case
never executed: case 'l':
'l':
never executed: case 'l':
0
59 login = 1;-
60 break;
never executed: break;
0
61 case
never executed: case 'a':
'a':
never executed: case 'a':
0
62 argv0 = list_optarg;-
63 break;
never executed: break;
0
64 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
65 default
executed 5 times by 1 test: default:
Executed by:
  • Self test
:
executed 5 times by 1 test: default:
Executed by:
  • Self test
5
66 builtin_usage ();-
67 return
executed 5 times by 1 test: return (258);
Executed by:
  • Self test
(258);
executed 5 times by 1 test: return (258);
Executed by:
  • Self test
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
list == 0Description
TRUEevaluated 259 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
3-259
79 return
executed 259 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 259 times by 1 test: return (0);
Executed by:
  • Self test
259
80-
81-
82 if (restricted
restrictedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
1-2
83 {-
84 sh_restricted ((char *)-
85 ((void *)0)-
86 );-
87 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
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])
absolute_program (args[0])Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? args[0] : search_for_command (args[0], 1);
0-2
98-
99 if (command == 0
command == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
100 {-
101 if (file_isdir (args[0])
file_isdir (args[0])Description
TRUEnever evaluated
FALSEnever evaluated
)
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: goto failed_exec;
failed_exec;
never executed: goto failed_exec;
0
122 }-
123-
124 com2 = full_pathname (command);-
125 if (com2
com2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
126 {-
127 if (command != args[0]
command != args[0]Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
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:
  • Self test
2
131-
132 if (argv0
argv0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
133 {-
134 sh_xfree((args[0]), "./exec.def", 179);-
135 args[0] = login
loginDescription
TRUEnever evaluated
FALSEnever evaluated
? mkdashname (argv0) : (char *)strcpy (sh_xmalloc((1 + strlen (argv0)), "./exec.def", 180), (argv0));
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
loginDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
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
cleanenv == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
(subshell_envi...t & 0x02) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
subshell_environment & 0x02) == 0
(subshell_envi...t & 0x02) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-2
152 adjust_shell_level (-1);
executed 1 time by 1 test: adjust_shell_level (-1);
Executed by:
  • Self test
1
153-
154 if (cleanenv
cleanenvDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
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:
  • Self test
2
164-
165-
166 if (interactive_shell
interactive_shellDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& subshell_environment == 0
subshell_environment == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
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
subshell_environment == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
174 end_job_control ();
executed 1 time by 1 test: end_job_control ();
Executed by:
  • Self test
1
175 if (interactive
interactiveDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| job_control
job_controlDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
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
cleanenv == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
188 adjust_shell_level (1);
executed 2 times by 1 test: adjust_shell_level (1);
Executed by:
  • Self test
2
189-
190 if (exit_value == 127
exit_value == 127Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
191 goto
executed 2 times by 1 test: goto failed_exec;
Executed by:
  • Self test
failed_exec;
executed 2 times by 1 test: goto failed_exec;
Executed by:
  • Self test
2
192 else if (executable_file (command) == 0
executable_file (command) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
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-
206failed_exec:
code before this statement never executed: failed_exec:
0
207 do { if (command
commandDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) sh_xfree((command), "./exec.def", 244);
executed 2 times by 1 test: sh_xfree((command), "./exec.def", 244);
Executed by:
  • Self test
} while (0);
0-2
208-
209 if (subshell_environment
subshell_environmentDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
|| (interactive == 0
interactive == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& no_exit_on_failed_exec == 0
no_exit_on_failed_exec == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
))
0-1
210 exit_shell (exit_value);
executed 1 time by 1 test: exit_shell (exit_value);
Executed by:
  • Self test
1
211-
212 if (args
argsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
213 strvec_dispose (args);
never executed: strvec_dispose (args);
0
214-
215 if (env
envDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& env != export_env
env != export_envDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
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
interactive_shellDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
|| job_control
job_controlDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
223 restart_job_control ();
never executed: restart_job_control ();
0
224-
225-
226 return
executed 1 time by 1 test: return (exit_value);
Executed by:
  • Self test
(exit_value);
executed 1 time by 1 test: return (exit_value);
Executed by:
  • Self test
1
227}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2