OpenCoverage

evalstring.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/evalstring.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* evalstring.c - evaluate a string as one or more shell commands. */-
2-
3/* Copyright (C) 1996-2017 Free Software Foundation, Inc.-
4-
5 This file is part of GNU Bash, the Bourne Again SHell.-
6-
7 Bash is free software: you can redistribute it and/or modify-
8 it under the terms of the GNU General Public License as published by-
9 the Free Software Foundation, either version 3 of the License, or-
10 (at your option) any later version.-
11-
12 Bash is distributed in the hope that it will be useful,-
13 but WITHOUT ANY WARRANTY; without even the implied warranty of-
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
15 GNU General Public License for more details.-
16-
17 You should have received a copy of the GNU General Public License-
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.-
19*/-
20-
21#include <config.h>-
22-
23#if defined (HAVE_UNISTD_H)-
24# ifdef _MINIX-
25# include <sys/types.h>-
26# endif-
27# include <unistd.h>-
28#endif-
29-
30#include <stdio.h>-
31#include <signal.h>-
32-
33#include <errno.h>-
34-
35#include "filecntl.h"-
36#include "../bashansi.h"-
37-
38#include "../shell.h"-
39#include "../jobs.h"-
40#include "../builtins.h"-
41#include "../flags.h"-
42#include "../parser.h"-
43#include "../input.h"-
44#include "../execute_cmd.h"-
45#include "../redir.h"-
46#include "../trap.h"-
47#include "../bashintl.h"-
48-
49#include <y.tab.h>-
50-
51#if defined (HISTORY)-
52# include "../bashhist.h"-
53#endif-
54-
55#include "common.h"-
56#include "builtext.h"-
57-
58#if !defined (errno)-
59extern int errno;-
60#endif-
61-
62#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)-
63-
64int parse_and_execute_level = 0;-
65-
66static int cat_file __P((REDIRECT *));-
67-
68#define PE_TAG "parse_and_execute top"-
69#define PS_TAG "parse_string top"-
70-
71#if defined (HISTORY)-
72static void-
73set_history_remembering ()-
74{-
75 remember_on_history = enable_history_list;-
76}
executed 723716 times by 1 test: end of block
Executed by:
  • Self test
723716
77#endif-
78-
79static void-
80restore_lastcom (x)-
81 char *x;-
82{-
83 FREE (the_printed_command_except_trap);
executed 724704 times by 1 test: sh_xfree((the_printed_command_except_trap), "evalstring.c", 83);
Executed by:
  • Self test
the_printed_co...nd_except_trapDescription
TRUEevaluated 724704 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-724704
84 the_printed_command_except_trap = x;-
85}
executed 724704 times by 1 test: end of block
Executed by:
  • Self test
724704
86-
87int-
88should_suppress_fork (command)-
89 COMMAND *command;-
90{-
91 return (startup_state == 2 && parse_and_execute_level == 1 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
92 running_trap == 0 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
93 *bash_input.location.string == '\0' &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
94 command->type == cm_simple &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
95 signal_is_trapped (EXIT_TRAP) == 0 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
96 signal_is_trapped (ERROR_TRAP) == 0 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
97 any_signals_trapped () < 0 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
98 command->redirects == 0 && command->value.Simple->redirects == 0 &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
99 ((command->flags & CMD_TIME_PIPELINE) == 0) &&
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
100 ((command->flags & CMD_INVERT_RETURN) == 0));
executed 22988 times by 1 test: return (startup_state == 2 && parse_and_execute_level == 1 && running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && signal_is_trapped (0) == 0 && signal_is_trapped ( 65 +1) == 0 && any_signals_trapped () < 0 && command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & 0x80) == 0) && ((command->flags & 0x04) == 0));
Executed by:
  • Self test
22988
101}-
102-
103void-
104optimize_fork (command)-
105 COMMAND *command;-
106{-
107 if (command->type == cm_connection &&
command->type == cm_connectionDescription
TRUEevaluated 11199 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11199
108 (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) &&
command->value...nnector == 288Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11170 times by 1 test
Evaluated by:
  • Self test
command->value...nnector == 289Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11145 times by 1 test
Evaluated by:
  • Self test
25-11170
109 should_suppress_fork (command->value.Connection->second))
should_suppres...ction->second)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 50 times by 1 test
Evaluated by:
  • Self test
4-50
110 {-
111 command->value.Connection->second->flags |= CMD_NO_FORK;-
112 command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK;-
113 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
114}
executed 11199 times by 1 test: end of block
Executed by:
  • Self test
11199
115-
116void-
117optimize_subshell_command (command)-
118 COMMAND *command;-
119{-
120 if (running_trap == 0 &&
running_trap == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
121 command->type == cm_simple &&
command->type == cm_simpleDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 signal_is_trapped (EXIT_TRAP) == 0 &&
signal_is_trapped (0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
123 signal_is_trapped (ERROR_TRAP) == 0 &&
signal_is_trap... ( 65 +1) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
124 any_signals_trapped () < 0 &&
any_signals_trapped () < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
125 command->redirects == 0 && command->value.Simple->redirects == 0 &&
command->redirects == 0Description
TRUEnever evaluated
FALSEnever evaluated
command->value...redirects == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
126 ((command->flags & CMD_TIME_PIPELINE) == 0) &&
((command->flags & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
127 ((command->flags & CMD_INVERT_RETURN) == 0))
((command->flags & 0x04) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
128 {-
129 command->flags |= CMD_NO_FORK;-
130 command->value.Simple->flags |= CMD_NO_FORK;-
131 }
never executed: end of block
0
132 else if (command->type == cm_connection &&
command->type == cm_connectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR))
command->value...nnector == 288Description
TRUEnever evaluated
FALSEnever evaluated
command->value...nnector == 289Description
TRUEnever evaluated
FALSEnever evaluated
0
134 optimize_subshell_command (command->value.Connection->second);
never executed: optimize_subshell_command (command->value.Connection->second);
0
135}
never executed: end of block
0
136 -
137/* How to force parse_and_execute () to clean up after itself. */-
138void-
139parse_and_execute_cleanup ()-
140{-
141 if (running_trap)
running_trapDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-8
142 {-
143 run_trap_cleanup (running_trap - 1);-
144 unfreeze_jobs_list ();-
145 }
never executed: end of block
0
146-
147 if (have_unwind_protects ())
have_unwind_protects ()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
148 run_unwind_frame (PE_TAG);
executed 8 times by 1 test: run_unwind_frame ("parse_and_execute top");
Executed by:
  • Self test
8
149 else-
150 parse_and_execute_level = 0; /* XXX */
never executed: parse_and_execute_level = 0;
0
151}-
152-
153static void-
154parse_prologue (string, flags, tag)-
155 char *string;-
156 int flags;-
157 char *tag;-
158{-
159 char *orig_string, *lastcom;-
160 int x;-
161-
162 orig_string = string;-
163 /* Unwind protect this invocation of parse_and_execute (). */-
164 begin_unwind_frame (tag);-
165 unwind_protect_int (parse_and_execute_level);-
166 unwind_protect_jmp_buf (top_level);-
167 unwind_protect_int (indirection_level);-
168 unwind_protect_int (line_number);-
169 unwind_protect_int (line_number_for_err_trap);-
170 unwind_protect_int (loop_level);-
171 unwind_protect_int (executing_list);-
172 unwind_protect_int (comsub_ignore_return);-
173 if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
flags & (0x001|0x002)Description
TRUEevaluated 708857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17710 times by 1 test
Evaluated by:
  • Self test
17710-708857
174 unwind_protect_int (interactive);
executed 708857 times by 1 test: unwind_protect_mem ((char *)&(interactive), sizeof (interactive));
Executed by:
  • Self test
708857
175-
176#if defined (HISTORY)-
177 if (parse_and_execute_level == 0)
parse_and_execute_level == 0Description
TRUEevaluated 725357 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1210 times by 1 test
Evaluated by:
  • Self test
1210-725357
178 add_unwind_protect (set_history_remembering, (char *)NULL);
executed 725357 times by 1 test: add_unwind_protect (set_history_remembering, (char *) ((void *)0) );
Executed by:
  • Self test
725357
179 else-
180 unwind_protect_int (remember_on_history); /* can be used in scripts */
executed 1210 times by 1 test: unwind_protect_mem ((char *)&(remember_on_history), sizeof (remember_on_history));
Executed by:
  • Self test
1210
181# if defined (BANG_HISTORY)-
182 unwind_protect_int (history_expansion_inhibited);-
183# endif /* BANG_HISTORY */-
184#endif /* HISTORY */-
185-
186 if (interactive_shell)
interactive_shellDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 726550 times by 1 test
Evaluated by:
  • Self test
17-726550
187 {-
188 x = get_current_prompt_level ();-
189 add_unwind_protect (set_current_prompt_level, x);-
190 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
191-
192 if (the_printed_command_except_trap)
the_printed_co...nd_except_trapDescription
TRUEevaluated 726323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 244 times by 1 test
Evaluated by:
  • Self test
244-726323
193 {-
194 lastcom = savestring (the_printed_command_except_trap);-
195 add_unwind_protect (restore_lastcom, lastcom);-
196 }
executed 726323 times by 1 test: end of block
Executed by:
  • Self test
726323
197-
198 add_unwind_protect (pop_stream, (char *)NULL);-
199 if (parser_expanding_alias ())
parser_expanding_alias ()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 726549 times by 1 test
Evaluated by:
  • Self test
18-726549
200 add_unwind_protect (parser_restore_alias, (char *)NULL);
executed 18 times by 1 test: add_unwind_protect (parser_restore_alias, (char *) ((void *)0) );
Executed by:
  • Self test
18
201-
202 if (orig_string && ((flags & SEVAL_NOFREE) == 0))
orig_stringDescription
TRUEevaluated 726567 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((flags & 0x008) == 0)Description
TRUEevaluated 21260 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-726567
203 add_unwind_protect (xfree, orig_string);
executed 21260 times by 1 test: add_unwind_protect (xfree, orig_string);
Executed by:
  • Self test
21260
204 end_unwind_frame ();-
205-
206 if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
flags & (0x001|0x002)Description
TRUEevaluated 708857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17710 times by 1 test
Evaluated by:
  • Self test
17710-708857
207 interactive = (flags & SEVAL_NONINT) ? 0 : 1;
executed 708857 times by 1 test: interactive = (flags & 0x001) ? 0 : 1;
Executed by:
  • Self test
(flags & 0x001)Description
TRUEevaluated 708857 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-708857
208-
209#if defined (HISTORY)-
210 if (flags & SEVAL_NOHIST)
flags & 0x004Description
TRUEevaluated 726565 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-726565
211 bash_history_disable ();
executed 726565 times by 1 test: bash_history_disable ();
Executed by:
  • Self test
726565
212# if defined (BANG_HISTORY)-
213 if (flags & SEVAL_NOHISTEXP)
flags & 0x200Description
TRUEnever evaluated
FALSEevaluated 726567 times by 1 test
Evaluated by:
  • Self test
0-726567
214 history_expansion_inhibited = 1;
never executed: history_expansion_inhibited = 1;
0
215# endif /* BANG_HISTORY */-
216#endif /* HISTORY */-
217}
executed 726567 times by 1 test: end of block
Executed by:
  • Self test
726567
218-
219/* Parse and execute the commands in STRING. Returns whatever-
220 execute_command () returns. This frees STRING. FLAGS is a-
221 flags word; look in common.h for the possible values. Actions-
222 are:-
223 (flags & SEVAL_NONINT) -> interactive = 0;-
224 (flags & SEVAL_INTERACT) -> interactive = 1;-
225 (flags & SEVAL_NOHIST) -> call bash_history_disable ()-
226 (flags & SEVAL_NOFREE) -> don't free STRING when finished-
227 (flags & SEVAL_RESETLINE) -> reset line_number to 1-
228 (flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1-
229*/-
230-
231int-
232parse_and_execute (string, from_file, flags)-
233 char *string;-
234 const char *from_file;-
235 int flags;-
236{-
237 int code, lreset;-
238 volatile int should_jump_to_top_level, last_result;-
239 COMMAND *volatile command;-
240 volatile sigset_t pe_sigmask;-
241-
242 parse_prologue (string, flags, PE_TAG);-
243-
244 parse_and_execute_level++;-
245-
246 lreset = flags & SEVAL_RESETLINE;-
247-
248#if defined (HAVE_POSIX_SIGNALS)-
249 /* If we longjmp and are going to go on, use this to restore signal mask */-
250 sigemptyset ((sigset_t *)&pe_sigmask);-
251 sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&pe_sigmask);-
252#endif-
253-
254 /* Reset the line number if the caller wants us to. If we don't reset the-
255 line number, we have to subtract one, because we will add one just-
256 before executing the next command (resetting the line number sets it to-
257 0; the first line number is 1). */-
258 push_stream (lreset);-
259 if (parser_expanding_alias ())
parser_expanding_alias ()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21242 times by 1 test
Evaluated by:
  • Self test
18-21242
260 /* push current shell_input_line */-
261 parser_save_alias ();
executed 18 times by 1 test: parser_save_alias ();
Executed by:
  • Self test
18
262 -
263 if (lreset == 0)
lreset == 0Description
TRUEevaluated 19862 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1398 times by 1 test
Evaluated by:
  • Self test
1398-19862
264 line_number--;
executed 19862 times by 1 test: line_number--;
Executed by:
  • Self test
19862
265 -
266 indirection_level++;-
267-
268 code = should_jump_to_top_level = 0;-
269 last_result = EXECUTION_SUCCESS;-
270-
271 /* We need to reset enough of the token state so we can start fresh. */-
272 if (current_token == yacc_EOF)
current_token == 304Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21259 times by 1 test
Evaluated by:
  • Self test
1-21259
273 current_token = '\n'; /* reset_parser() ? */
executed 1 time by 1 test: current_token = '\n';
Executed by:
  • Self test
1
274-
275 with_input_from_string (string, from_file);-
276 clear_shell_input_line ();-
277 while (*(bash_input.location.string))
*(bash_input.location.string)Description
TRUEevaluated 24963 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19474 times by 1 test
Evaluated by:
  • Self test
19474-24963
278 {-
279 command = (COMMAND *)NULL;-
280-
281 if (interrupt_state)
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 24963 times by 1 test
Evaluated by:
  • Self test
0-24963
282 {-
283 last_result = EXECUTION_FAILURE;-
284 break;
never executed: break;
0
285 }-
286-
287 /* Provide a location for functions which `longjmp (top_level)' to-
288 jump to. This prevents errors in substitution from restarting-
289 the reader loop directly, for example. */-
290 code = setjmp_nosigs (top_level);-
291-
292 if (code)
codeDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24963 times by 1 test
Evaluated by:
  • Self test
66-24963
293 {-
294 should_jump_to_top_level = 0;-
295 switch (code)-
296 {-
297 case ERREXIT:
executed 14 times by 1 test: case 4:
Executed by:
  • Self test
14
298 /* variable_context -> 0 is what eval.c:reader_loop() does in-
299 these circumstances. Don't bother with cleanup here because-
300 we don't want to run the function execution cleanup stuff-
301 that will cause pop_context and other functions to run.-
302 XXX - change that if we want the function context to be-
303 unwound. */-
304 if (exit_immediately_on_error && variable_context)
exit_immediately_on_errorDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
variable_contextDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
0-14
305 {-
306 discard_unwind_frame ("pe_dispose");-
307 variable_context = 0; /* not in a function */-
308 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
309 should_jump_to_top_level = 1;-
310 goto out;
executed 14 times by 1 test: goto out;
Executed by:
  • Self test
14
311 case FORCE_EOF:
executed 38 times by 1 test: case 1:
Executed by:
  • Self test
38
312 case EXITPROG:
executed 7 times by 1 test: case 3:
Executed by:
  • Self test
7
313 if (command)
commandDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-45
314 run_unwind_frame ("pe_dispose");
executed 45 times by 1 test: run_unwind_frame ("pe_dispose");
Executed by:
  • Self test
45
315 /* Remember to call longjmp (top_level) after the old-
316 value for it is restored. */-
317 should_jump_to_top_level = 1;-
318 goto out;
executed 45 times by 1 test: goto out;
Executed by:
  • Self test
45
319-
320 case DISCARD:
executed 7 times by 1 test: case 2:
Executed by:
  • Self test
7
321 if (command)
commandDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
322 run_unwind_frame ("pe_dispose");
executed 7 times by 1 test: run_unwind_frame ("pe_dispose");
Executed by:
  • Self test
7
323 last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */-
324 if (subshell_environment)
subshell_environmentDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-7
325 {-
326 should_jump_to_top_level = 1;-
327 goto out;
never executed: goto out;
0
328 }-
329 else-
330 {-
331#if 0-
332 dispose_command (command); /* pe_dispose does this */-
333#endif-
334#if defined (HAVE_POSIX_SIGNALS)-
335 sigprocmask (SIG_SETMASK, (sigset_t *)&pe_sigmask, (sigset_t *)NULL);-
336#endif-
337 continue;
executed 7 times by 1 test: continue;
Executed by:
  • Self test
7
338 }-
339-
340 default:
never executed: default:
0
341 command_error ("parse_and_execute", CMDERR_BADJUMP, code, 0);-
342 break;
never executed: break;
0
343 }-
344 }-
345 -
346 if (parse_command () == 0)
parse_command () == 0Description
TRUEevaluated 24947 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-24947
347 {-
348 if ((flags & SEVAL_PARSEONLY) || (interactive_shell == 0 && read_but_dont_execute))
(flags & 0x020)Description
TRUEnever evaluated
FALSEevaluated 24947 times by 1 test
Evaluated by:
  • Self test
interactive_shell == 0Description
TRUEevaluated 23240 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1707 times by 1 test
Evaluated by:
  • Self test
read_but_dont_executeDescription
TRUEnever evaluated
FALSEevaluated 23240 times by 1 test
Evaluated by:
  • Self test
0-24947
349 {-
350 last_result = EXECUTION_SUCCESS;-
351 dispose_command (global_command);-
352 global_command = (COMMAND *)NULL;-
353 }
never executed: end of block
0
354 else if (command = global_command)
command = global_commandDescription
TRUEevaluated 22939 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2008 times by 1 test
Evaluated by:
  • Self test
2008-22939
355 {-
356 struct fd_bitmap *bitmap;-
357-
358 if (flags & SEVAL_FUNCDEF)
flags & 0x080Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22885 times by 1 test
Evaluated by:
  • Self test
54-22885
359 {-
360 char *x;-
361-
362 /* If the command parses to something other than a straight-
363 function definition, or if we have not consumed the entire-
364 string, or if the parser has transformed the function-
365 name (as parsing will if it begins or ends with shell-
366 whitespace, for example), reject the attempt */-
367 if (command->type != cm_function_def ||
command->type ...m_function_defDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
2-52
368 ((x = parser_remaining_input ()) && *x) ||
(x = parser_re...ning_input ())Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*xDescription
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
0-52
369 (STREQ (from_file, command->value.Function_def->name->word) == 0))
never executed: __result = (((const unsigned char *) (const char *) ( from_file ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( command->value.Function_def->name->word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(((from_file)[...}) == 0) == 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
(from_file)[0]...name->word)[0]Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-49
370 {-
371 internal_warning (_("%s: ignoring function definition attempt"), from_file);-
372 should_jump_to_top_level = 0;-
373 last_result = last_command_exit_value = EX_BADUSAGE;-
374 reset_parser ();-
375 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
376 }-
377 }
executed 49 times by 1 test: end of block
Executed by:
  • Self test
49
378-
379 bitmap = new_fd_bitmap (FD_BITMAP_SIZE);-
380 begin_unwind_frame ("pe_dispose");-
381 add_unwind_protect (dispose_fd_bitmap, bitmap);-
382 add_unwind_protect (dispose_command, command); /* XXX */-
383-
384 global_command = (COMMAND *)NULL;-
385-
386 if ((subshell_environment & SUBSHELL_COMSUB) && comsub_ignore_return)
(subshell_environment & 0x04)Description
TRUEevaluated 4375 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18559 times by 1 test
Evaluated by:
  • Self test
comsub_ignore_returnDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4364 times by 1 test
Evaluated by:
  • Self test
11-18559
387 command->flags |= CMD_IGNORE_RETURN;
executed 11 times by 1 test: command->flags |= 0x08;
Executed by:
  • Self test
11
388-
389#if defined (ONESHOT)-
390 /*-
391 * IF-
392 * we were invoked as `bash -c' (startup_state == 2) AND-
393 * parse_and_execute has not been called recursively AND-
394 * we're not running a trap AND-
395 * we have parsed the full command (string == '\0') AND-
396 * we're not going to run the exit trap AND-
397 * we have a simple command without redirections AND-
398 * the command is not being timed AND-
399 * the command's return status is not being inverted AND-
400 * there aren't any traps in effect-
401 * THEN-
402 * tell the execution code that we don't need to fork-
403 */-
404 if (should_suppress_fork (command))
should_suppress_fork (command)Description
TRUEevaluated 328 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22606 times by 1 test
Evaluated by:
  • Self test
328-22606
405 {-
406 command->flags |= CMD_NO_FORK;-
407 command->value.Simple->flags |= CMD_NO_FORK;-
408 }
executed 328 times by 1 test: end of block
Executed by:
  • Self test
328
409 else if (command->type == cm_connection)
command->type == cm_connectionDescription
TRUEevaluated 11199 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11407 times by 1 test
Evaluated by:
  • Self test
11199-11407
410 optimize_fork (command);
executed 11199 times by 1 test: optimize_fork (command);
Executed by:
  • Self test
11199
411#endif /* ONESHOT */-
412-
413 /* See if this is a candidate for $( <file ). */-
414 if (startup_state == 2 &&
startup_state == 2Description
TRUEevaluated 3182 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19752 times by 1 test
Evaluated by:
  • Self test
3182-19752
415 (subshell_environment & SUBSHELL_COMSUB) &&
(subshell_environment & 0x04)Description
TRUEevaluated 2992 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 190 times by 1 test
Evaluated by:
  • Self test
190-2992
416 *bash_input.location.string == '\0' &&
*bash_input.lo...string == '\0'Description
TRUEevaluated 2973 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
19-2973
417 command->type == cm_simple && !command->redirects &&
command->type == cm_simpleDescription
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2656 times by 1 test
Evaluated by:
  • Self test
!command->redirectsDescription
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2656
418 (command->flags & CMD_TIME_PIPELINE) == 0 &&
(command->flags & 0x80) == 0Description
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-317
419 command->value.Simple->words == 0 &&
command->value...le->words == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 310 times by 1 test
Evaluated by:
  • Self test
7-310
420 command->value.Simple->redirects &&
command->value...ple->redirectsDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
421 command->value.Simple->redirects->next == 0 &&
command->value...cts->next == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
422 command->value.Simple->redirects->instruction == r_input_direction &&
command->value...nput_directionDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
423 command->value.Simple->redirects->redirector.dest == 0)
command->value...ctor.dest == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-5
424 {-
425 int r;-
426 r = cat_file (command->value.Simple->redirects);-
427 last_result = (r < 0) ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
(r < 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
428 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
429 else-
430 last_result = execute_command_internal
executed 22929 times by 1 test: last_result = execute_command_internal (command, 0, -1, -1, bitmap);
Executed by:
  • Self test
22929
431 (command, 0, NO_PIPE, NO_PIPE, bitmap);
executed 22929 times by 1 test: last_result = execute_command_internal (command, 0, -1, -1, bitmap);
Executed by:
  • Self test
22929
432 dispose_command (command);-
433 dispose_fd_bitmap (bitmap);-
434 discard_unwind_frame ("pe_dispose");-
435-
436 if (flags & SEVAL_ONECMD)
flags & 0x100Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21162 times by 1 test
Evaluated by:
  • Self test
49-21162
437 {-
438 reset_parser ();-
439 break;
executed 49 times by 1 test: break;
Executed by:
  • Self test
49
440 }-
441 }
executed 21162 times by 1 test: end of block
Executed by:
  • Self test
21162
442 }
executed 23170 times by 1 test: end of block
Executed by:
  • Self test
23170
443 else-
444 {-
445 last_result = EXECUTION_FAILURE;-
446-
447 if (interactive_shell == 0 && this_shell_builtin &&
interactive_shell == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
this_shell_builtinDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-16
448 (this_shell_builtin == source_builtin || this_shell_builtin == eval_builtin) &&
this_shell_bui...source_builtinDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
this_shell_bui...= eval_builtinDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
449 last_command_exit_value == EX_BADSYNTAX && posixly_correct)
last_command_exit_value == 257Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
450 {-
451 should_jump_to_top_level = 1;-
452 code = ERREXIT;-
453 last_command_exit_value = EX_BADUSAGE;-
454 }
never executed: end of block
0
455-
456 /* Since we are shell compatible, syntax errors in a script-
457 abort the execution of the script. Right? */-
458 break;
executed 16 times by 1 test: break;
Executed by:
  • Self test
16
459 }-
460 }-
461-
462 out:
code before this statement executed 19544 times by 1 test: out:
Executed by:
  • Self test
19544
463-
464 run_unwind_frame (PE_TAG);-
465-
466 if (interrupt_state && parse_and_execute_level == 0)
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 19603 times by 1 test
Evaluated by:
  • Self test
parse_and_execute_level == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-19603
467 {-
468 /* An interrupt during non-interactive execution in an-
469 interactive shell (e.g. via $PROMPT_COMMAND) should-
470 not cause the shell to exit. */-
471 interactive = interactive_shell;-
472 throw_to_top_level ();-
473 }
never executed: end of block
0
474-
475 if (should_jump_to_top_level)
should_jump_to_top_levelDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19544 times by 1 test
Evaluated by:
  • Self test
59-19544
476 jump_to_top_level (code);
executed 59 times by 1 test: jump_to_top_level (code);
Executed by:
  • Self test
59
477-
478 return (last_result);
executed 19544 times by 1 test: return (last_result);
Executed by:
  • Self test
19544
479}-
480-
481/* Parse a command contained in STRING according to FLAGS and return the-
482 number of characters consumed from the string. If non-NULL, set *ENDP-
483 to the position in the string where the parse ended. Used to validate-
484 command substitutions during parsing to obey Posix rules about finding-
485 the end of the command and balancing parens. */-
486int-
487parse_string (string, from_file, flags, endp)-
488 char *string;-
489 const char *from_file;-
490 int flags;-
491 char **endp;-
492{-
493 int code, nc;-
494 volatile int should_jump_to_top_level;-
495 COMMAND *volatile command, *oglobal;-
496 char *ostring;-
497 volatile sigset_t ps_sigmask;-
498-
499 parse_prologue (string, flags, PS_TAG);-
500-
501#if defined (HAVE_POSIX_SIGNALS)-
502 /* If we longjmp and are going to go on, use this to restore signal mask */-
503 sigemptyset ((sigset_t *)&ps_sigmask);-
504 sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&ps_sigmask);-
505#endif-
506-
507/*itrace("parse_string: `%s'", string);*/-
508 /* Reset the line number if the caller wants us to. If we don't reset the-
509 line number, we have to subtract one, because we will add one just-
510 before executing the next command (resetting the line number sets it to-
511 0; the first line number is 1). */-
512 push_stream (0);-
513 if (parser_expanding_alias ())
parser_expanding_alias ()Description
TRUEnever evaluated
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-705307
514 /* push current shell_input_line */-
515 parser_save_alias ();
never executed: parser_save_alias ();
0
516-
517 code = should_jump_to_top_level = 0;-
518 oglobal = global_command;-
519 ostring = string;-
520-
521 with_input_from_string (string, from_file);-
522 while (*(bash_input.location.string))
*(bash_input.location.string)Description
TRUEevaluated 706586 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
11-706586
523 {-
524 command = (COMMAND *)NULL;-
525-
526#if 0-
527 if (interrupt_state)-
528 break;-
529#endif-
530-
531 /* Provide a location for functions which `longjmp (top_level)' to-
532 jump to. */-
533 code = setjmp_nosigs (top_level);-
534-
535 if (code)
codeDescription
TRUEnever evaluated
FALSEevaluated 706586 times by 1 test
Evaluated by:
  • Self test
0-706586
536 {-
537#if defined (DEBUG)-
538itrace("parse_string: longjmp executed: code = %d", code);-
539#endif-
540 should_jump_to_top_level = 0;-
541 switch (code)-
542 {-
543 case FORCE_EOF:
never executed: case 1:
0
544 case ERREXIT:
never executed: case 4:
0
545 case EXITPROG:
never executed: case 3:
0
546 case DISCARD: /* XXX */
never executed: case 2:
0
547 if (command)
commandDescription
TRUEnever evaluated
FALSEnever evaluated
0
548 dispose_command (command);
never executed: dispose_command (command);
0
549 /* Remember to call longjmp (top_level) after the old-
550 value for it is restored. */-
551 should_jump_to_top_level = 1;-
552 goto out;
never executed: goto out;
0
553-
554 default:
never executed: default:
0
555#if defined (HAVE_POSIX_SIGNALS)-
556 sigprocmask (SIG_SETMASK, (sigset_t *)&ps_sigmask, (sigset_t *)NULL);-
557#endif-
558 command_error ("parse_string", CMDERR_BADJUMP, code, 0);-
559 break;
never executed: break;
0
560 }-
561 }-
562 -
563 if (parse_command () == 0)
parse_command () == 0Description
TRUEevaluated 706579 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7-706579
564 {-
565 dispose_command (global_command);-
566 global_command = (COMMAND *)NULL;-
567 }
executed 706579 times by 1 test: end of block
Executed by:
  • Self test
706579
568 else-
569 {-
570 if ((flags & SEVAL_NOLONGJMP) == 0)
(flags & 0x040) == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
571 {-
572 should_jump_to_top_level = 1;-
573 code = DISCARD;-
574 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
575 else-
576 reset_parser (); /* XXX - sets token_to_read */
never executed: reset_parser ();
0
577 break;
executed 7 times by 1 test: break;
Executed by:
  • Self test
7
578 }-
579-
580 if (current_token == yacc_EOF || current_token == shell_eof_token)
current_token == 304Description
TRUEevaluated 961 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705618 times by 1 test
Evaluated by:
  • Self test
current_token ...hell_eof_tokenDescription
TRUEevaluated 704328 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1290 times by 1 test
Evaluated by:
  • Self test
961-705618
581 break;
executed 705289 times by 1 test: break;
Executed by:
  • Self test
705289
582 }
executed 1290 times by 1 test: end of block
Executed by:
  • Self test
1290
583-
584 out:
code before this statement executed 705307 times by 1 test: out:
Executed by:
  • Self test
705307
585-
586 global_command = oglobal;-
587 nc = bash_input.location.string - ostring;-
588 if (endp)
endpDescription
TRUEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-705307
589 *endp = bash_input.location.string;
executed 705307 times by 1 test: *endp = bash_input.location.string;
Executed by:
  • Self test
705307
590-
591 run_unwind_frame (PS_TAG);-
592-
593 /* If we return < 0, the caller (xparse_dolparen) will jump_to_top_level for-
594 us, after doing cleanup */-
595 if (should_jump_to_top_level)
should_jump_to_top_levelDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705300 times by 1 test
Evaluated by:
  • Self test
7-705300
596 {-
597 if (parse_and_execute_level == 0)
parse_and_execute_level == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
598 top_level_cleanup ();
executed 7 times by 1 test: top_level_cleanup ();
Executed by:
  • Self test
7
599 if (code == DISCARD)
code == 2Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
600 return -DISCARD;
executed 7 times by 1 test: return -2;
Executed by:
  • Self test
7
601 jump_to_top_level (code);-
602 }
never executed: end of block
0
603-
604 return (nc);
executed 705300 times by 1 test: return (nc);
Executed by:
  • Self test
705300
605}-
606-
607/* Handle a $( < file ) command substitution. This expands the filename,-
608 returning errors as appropriate, then just cats the file to the standard-
609 output. */-
610static int-
611cat_file (r)-
612 REDIRECT *r;-
613{-
614 char *fn;-
615 int fd, rval;-
616-
617 if (r->instruction != r_input_direction)
r->instruction...nput_directionDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
618 return -1;
never executed: return -1;
0
619-
620 /* Get the filename. */-
621 if (posixly_correct && !interactive_shell)
posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
!interactive_shellDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
622 disallow_filename_globbing++;
executed 1 time by 1 test: disallow_filename_globbing++;
Executed by:
  • Self test
1
623 fn = redirection_expand (r->redirectee.filename);-
624 if (posixly_correct && !interactive_shell)
posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
!interactive_shellDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
625 disallow_filename_globbing--;
executed 1 time by 1 test: disallow_filename_globbing--;
Executed by:
  • Self test
1
626-
627 if (fn == 0)
fn == 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
628 {-
629 redirection_error (r, AMBIGUOUS_REDIRECT);-
630 return -1;
never executed: return -1;
0
631 }-
632-
633 fd = open(fn, O_RDONLY);-
634 if (fd < 0)
fd < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
635 {-
636 file_error (fn);-
637 free (fn);-
638 return -1;
executed 2 times by 1 test: return -1;
Executed by:
  • Self test
2
639 }-
640-
641 rval = zcatfd (fd, 1, fn);-
642-
643 free (fn);-
644 close (fd);-
645-
646 return (rval);
executed 3 times by 1 test: return (rval);
Executed by:
  • Self test
3
647}-
648-
649int-
650evalstring (string, from_file, flags)-
651 char *string;-
652 const char *from_file;-
653 int flags;-
654{-
655 volatile int r, rflag, rcatch;-
656-
657 rcatch = 0;-
658 rflag = return_catch_flag;-
659 /* If we are in a place where `return' is valid, we have to catch-
660 `eval "... return"' and make sure parse_and_execute cleans up. Then-
661 we can trampoline to the previous saved return_catch location. */-
662 if (rflag)
rflagDescription
TRUEevaluated 6821 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6393 times by 1 test
Evaluated by:
  • Self test
6393-6821
663 {-
664 begin_unwind_frame ("evalstring");-
665-
666 unwind_protect_int (return_catch_flag);-
667 unwind_protect_jmp_buf (return_catch);-
668-
669 return_catch_flag++; /* increment so we have a counter */-
670 rcatch = setjmp_nosigs (return_catch);-
671 }
executed 6821 times by 1 test: end of block
Executed by:
  • Self test
6821
672-
673 if (rcatch)
rcatchDescription
TRUEnever evaluated
FALSEevaluated 13214 times by 1 test
Evaluated by:
  • Self test
0-13214
674 {-
675 parse_and_execute_cleanup ();-
676 r = return_catch_value;-
677 }
never executed: end of block
0
678 else-
679 /* Note that parse_and_execute () frees the string it is passed. */-
680 r = parse_and_execute (string, from_file, flags);
executed 13214 times by 1 test: r = parse_and_execute (string, from_file, flags);
Executed by:
  • Self test
13214
681-
682 if (rflag)
rflagDescription
TRUEevaluated 6821 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6385 times by 1 test
Evaluated by:
  • Self test
6385-6821
683 {-
684 run_unwind_frame ("evalstring");-
685 if (rcatch && return_catch_flag)
rcatchDescription
TRUEnever evaluated
FALSEevaluated 6821 times by 1 test
Evaluated by:
  • Self test
return_catch_flagDescription
TRUEnever evaluated
FALSEnever evaluated
0-6821
686 {-
687 return_catch_value = r;-
688 sh_longjmp (return_catch, 1);-
689 }
never executed: end of block
0
690 }
executed 6821 times by 1 test: end of block
Executed by:
  • Self test
6821
691 -
692 return (r);
executed 13206 times by 1 test: return (r);
Executed by:
  • Self test
13206
693}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2