OpenCoverage

parse.y

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/parse.y
Source codeSwitch to Preprocessed file
LineSourceCount
1/* parse.y - Yacc grammar for bash. */-
2-
3/* Copyright (C) 1989-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%{-
22#include "config.h"-
23-
24#include "bashtypes.h"-
25#include "bashansi.h"-
26-
27#include "filecntl.h"-
28-
29#if defined (HAVE_UNISTD_H)-
30# include <unistd.h>-
31#endif-
32-
33#if defined (HAVE_LOCALE_H)-
34# include <locale.h>-
35#endif-
36-
37#include <stdio.h>-
38#include "chartypes.h"-
39#include <signal.h>-
40-
41#include "memalloc.h"-
42-
43#include "bashintl.h"-
44-
45#define NEED_STRFTIME_DECL /* used in externs.h */-
46-
47#include "shell.h"-
48#include "execute_cmd.h"-
49#include "typemax.h" /* SIZE_MAX if needed */-
50#include "trap.h"-
51#include "flags.h"-
52#include "parser.h"-
53#include "mailcheck.h"-
54#include "test.h"-
55#include "builtins.h"-
56#include "builtins/common.h"-
57#include "builtins/builtext.h"-
58-
59#include "shmbutil.h"-
60-
61#if defined (READLINE)-
62# include "bashline.h"-
63# include <readline/readline.h>-
64#endif /* READLINE */-
65-
66#if defined (HISTORY)-
67# include "bashhist.h"-
68# include <readline/history.h>-
69#endif /* HISTORY */-
70-
71#if defined (JOB_CONTROL)-
72# include "jobs.h"-
73#else-
74extern int cleanup_dead_jobs __P((void));-
75#endif /* JOB_CONTROL */-
76-
77#if defined (ALIAS)-
78# include "alias.h"-
79#else-
80typedef void *alias_t;-
81#endif /* ALIAS */-
82-
83#if defined (PROMPT_STRING_DECODE)-
84# ifndef _MINIX-
85# include <sys/param.h>-
86# endif-
87# include <time.h>-
88# if defined (TM_IN_SYS_TIME)-
89# include <sys/types.h>-
90# include <sys/time.h>-
91# endif /* TM_IN_SYS_TIME */-
92# include "maxpath.h"-
93#endif /* PROMPT_STRING_DECODE */-
94-
95#define RE_READ_TOKEN -99-
96#define NO_EXPANSION -100-
97-
98#define END_ALIAS -2-
99-
100#ifdef DEBUG-
101# define YYDEBUG 1-
102#else-
103# define YYDEBUG 0-
104#endif-
105-
106#if defined (HANDLE_MULTIBYTE)-
107# define last_shell_getc_is_singlebyte \-
108 ((shell_input_line_index > 1) \-
109 ? shell_input_line_property[shell_input_line_index - 1] \-
110 : 1)-
111# define MBTEST(x) ((x) && last_shell_getc_is_singlebyte)-
112#else-
113# define last_shell_getc_is_singlebyte 1-
114# define MBTEST(x) ((x))-
115#endif-
116-
117#if defined (EXTENDED_GLOB)-
118extern int extended_glob;-
119#endif-
120-
121extern int dump_translatable_strings, dump_po_strings;-
122-
123#if !defined (errno)-
124extern int errno;-
125#endif-
126-
127/* **************************************************************** */-
128/* */-
129/* "Forward" declarations */-
130/* */-
131/* **************************************************************** */-
132-
133#ifdef DEBUG-
134static void debug_parser __P((int));-
135#endif-
136-
137static int yy_getc __P((void));-
138static int yy_ungetc __P((int));-
139-
140#if defined (READLINE)-
141static int yy_readline_get __P((void));-
142static int yy_readline_unget __P((int));-
143#endif-
144-
145static int yy_string_get __P((void));-
146static int yy_string_unget __P((int));-
147static void rewind_input_string __P((void));-
148static int yy_stream_get __P((void));-
149static int yy_stream_unget __P((int));-
150-
151static int shell_getc __P((int));-
152static void shell_ungetc __P((int));-
153static void discard_until __P((int));-
154-
155#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
156static void push_string __P((char *, int, alias_t *));-
157static void pop_string __P((void));-
158static void free_string_list __P((void));-
159#endif-
160-
161static char *read_a_line __P((int));-
162-
163static int reserved_word_acceptable __P((int));-
164static int yylex __P((void));-
165-
166static void push_heredoc __P((REDIRECT *));-
167static char *mk_alexpansion __P((char *));-
168static int alias_expand_token __P((char *));-
169static int time_command_acceptable __P((void));-
170static int special_case_tokens __P((char *));-
171static int read_token __P((int));-
172static char *parse_matched_pair __P((int, int, int, int *, int));-
173static char *parse_comsub __P((int, int, int, int *, int));-
174#if defined (ARRAY_VARS)-
175static char *parse_compound_assignment __P((int *));-
176#endif-
177#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)-
178static int parse_dparen __P((int));-
179static int parse_arith_cmd __P((char **, int));-
180#endif-
181#if defined (COND_COMMAND)-
182static void cond_error __P((void));-
183static COND_COM *cond_expr __P((void));-
184static COND_COM *cond_or __P((void));-
185static COND_COM *cond_and __P((void));-
186static COND_COM *cond_term __P((void));-
187static int cond_skip_newlines __P((void));-
188static COMMAND *parse_cond_command __P((void));-
189#endif-
190#if defined (ARRAY_VARS)-
191static int token_is_assignment __P((char *, int));-
192static int token_is_ident __P((char *, int));-
193#endif-
194static int read_token_word __P((int));-
195static void discard_parser_constructs __P((int));-
196-
197static char *error_token_from_token __P((int));-
198static char *error_token_from_text __P((void));-
199static void print_offending_line __P((void));-
200static void report_syntax_error __P((char *));-
201-
202static void handle_eof_input_unit __P((void));-
203static void prompt_again __P((void));-
204#if 0-
205static void reset_readline_prompt __P((void));-
206#endif-
207static void print_prompt __P((void));-
208-
209#if defined (HANDLE_MULTIBYTE)-
210static void set_line_mbstate __P((void));-
211static char *shell_input_line_property = NULL;-
212static size_t shell_input_line_propsize = 0;-
213#else-
214# define set_line_mbstate()-
215#endif-
216-
217extern int yyerror __P((const char *));-
218-
219#ifdef DEBUG-
220extern int yydebug;-
221#endif-
222-
223/* Default prompt strings */-
224char *primary_prompt = PPROMPT;-
225char *secondary_prompt = SPROMPT;-
226-
227/* PROMPT_STRING_POINTER points to one of these, never to an actual string. */-
228char *ps1_prompt, *ps2_prompt;-
229-
230/* Displayed after reading a command but before executing it in an interactive shell */-
231char *ps0_prompt;-
232-
233/* Handle on the current prompt string. Indirectly points through-
234 ps1_ or ps2_prompt. */-
235char **prompt_string_pointer = (char **)NULL;-
236char *current_prompt_string;-
237-
238/* Non-zero means we expand aliases in commands. */-
239int expand_aliases = 0;-
240-
241/* If non-zero, the decoded prompt string undergoes parameter and-
242 variable substitution, command substitution, arithmetic substitution,-
243 string expansion, process substitution, and quote removal in-
244 decode_prompt_string. */-
245int promptvars = 1;-
246-
247/* If non-zero, $'...' and $"..." are expanded when they appear within-
248 a ${...} expansion, even when the expansion appears within double-
249 quotes. */-
250int extended_quote = 1;-
251-
252/* The number of lines read from input while creating the current command. */-
253int current_command_line_count;-
254-
255/* The number of lines in a command saved while we run parse_and_execute */-
256int saved_command_line_count;-
257-
258/* The token that currently denotes the end of parse. */-
259int shell_eof_token;-
260-
261/* The token currently being read. */-
262int current_token;-
263-
264/* The current parser state. */-
265int parser_state;-
266-
267/* Variables to manage the task of reading here documents, because we need to-
268 defer the reading until after a complete command has been collected. */-
269static REDIRECT *redir_stack[HEREDOC_MAX];-
270int need_here_doc;-
271-
272/* Where shell input comes from. History expansion is performed on each-
273 line when the shell is interactive. */-
274static char *shell_input_line = (char *)NULL;-
275static size_t shell_input_line_index;-
276static size_t shell_input_line_size; /* Amount allocated for shell_input_line. */-
277static size_t shell_input_line_len; /* strlen (shell_input_line) */-
278-
279/* Either zero or EOF. */-
280static int shell_input_line_terminator;-
281-
282/* The line number in a script on which a function definition starts. */-
283static int function_dstart;-
284-
285/* The line number in a script on which a function body starts. */-
286static int function_bstart;-
287-
288/* The line number in a script at which an arithmetic for command starts. */-
289static int arith_for_lineno;-
290-
291/* The decoded prompt string. Used if READLINE is not defined or if-
292 editing is turned off. Analogous to current_readline_prompt. */-
293static char *current_decoded_prompt;-
294-
295/* The last read token, or NULL. read_token () uses this for context-
296 checking. */-
297static int last_read_token;-
298-
299/* The token read prior to last_read_token. */-
300static int token_before_that;-
301-
302/* The token read prior to token_before_that. */-
303static int two_tokens_ago;-
304-
305static int global_extglob;-
306-
307/* The line number in a script where the word in a `case WORD', `select WORD'-
308 or `for WORD' begins. This is a nested command maximum, since the array-
309 index is decremented after a case, select, or for command is parsed. */-
310#define MAX_CASE_NEST 128-
311static int word_lineno[MAX_CASE_NEST+1];-
312static int word_top = -1;-
313-
314/* If non-zero, it is the token that we want read_token to return-
315 regardless of what text is (or isn't) present to be read. This-
316 is reset by read_token. If token_to_read == WORD or-
317 ASSIGNMENT_WORD, yylval.word should be set to word_desc_to_read. */-
318static int token_to_read;-
319static WORD_DESC *word_desc_to_read;-
320-
321static REDIRECTEE source;-
322static REDIRECTEE redir;-
323-
324static FILE *yyoutstream;-
325static FILE *yyerrstream;-
326%}-
327-
328%union {-
329 WORD_DESC *word; /* the word that we read. */-
330 int number; /* the number that we read. */-
331 WORD_LIST *word_list;-
332 COMMAND *command;-
333 REDIRECT *redirect;-
334 ELEMENT element;-
335 PATTERN_LIST *pattern;-
336}-
337-
338/* Reserved words. Members of the first group are only recognized-
339 in the case that they are preceded by a list_terminator. Members-
340 of the second group are for [[...]] commands. Members of the-
341 third group are recognized only under special circumstances. */-
342%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION COPROC-
343%token COND_START COND_END COND_ERROR-
344%token IN BANG TIME TIMEOPT TIMEIGN-
345-
346/* More general tokens. yylex () knows how to make these. */-
347%token <word> WORD ASSIGNMENT_WORD REDIR_WORD-
348%token <number> NUMBER-
349%token <word_list> ARITH_CMD ARITH_FOR_EXPRS-
350%token <command> COND_CMD-
351%token AND_AND OR_OR GREATER_GREATER LESS_LESS LESS_AND LESS_LESS_LESS-
352%token GREATER_AND SEMI_SEMI SEMI_AND SEMI_SEMI_AND-
353%token LESS_LESS_MINUS AND_GREATER AND_GREATER_GREATER LESS_GREATER-
354%token GREATER_BAR BAR_AND-
355-
356/* The types that the various syntactical units return. */-
357-
358%type <command> inputunit command pipeline pipeline_command-
359%type <command> list list0 list1 compound_list simple_list simple_list1-
360%type <command> simple_command shell_command-
361%type <command> for_command select_command case_command group_command-
362%type <command> arith_command-
363%type <command> cond_command-
364%type <command> arith_for_command-
365%type <command> coproc-
366%type <command> function_def function_body if_command elif_clause subshell-
367%type <redirect> redirection redirection_list-
368%type <element> simple_command_element-
369%type <word_list> word_list pattern-
370%type <pattern> pattern_list case_clause_sequence case_clause-
371%type <number> timespec-
372%type <number> list_terminator-
373-
374%start inputunit-
375-
376%left '&' ';' '\n' yacc_EOF-
377%left AND_AND OR_OR-
378%right '|' BAR_AND-
379%%-
380-
381inputunit: simple_list simple_list_terminator-
382 {-
383 /* Case of regular command. Discard the error-
384 safety net,and return the command just parsed. */-
385 global_command = $1;-
386 eof_encountered = 0;-
387 /* discard_parser_constructs (0); */-
388 if (parser_state & PST_CMDSUBST)
parser_state & 0x000040Description
TRUEevaluated 838 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 119351 times by 1 test
Evaluated by:
  • Self test
838-119351
389 parser_state |= PST_EOFTOKEN;
executed 838 times by 1 test: parser_state |= 0x008000;
Executed by:
  • Self test
838
390 YYACCEPT;
executed 120189 times by 1 test: goto yyacceptlab;
Executed by:
  • Self test
120189
391 }-
392 | '\n'-
393 {-
394 /* Case of regular command, but not a very-
395 interesting one. Return a NULL command. */-
396 global_command = (COMMAND *)NULL;-
397 if (parser_state & PST_CMDSUBST)
parser_state & 0x000040Description
TRUEevaluated 452 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 81648 times by 1 test
Evaluated by:
  • Self test
452-81648
398 parser_state |= PST_EOFTOKEN;
executed 452 times by 1 test: parser_state |= 0x008000;
Executed by:
  • Self test
452
399 YYACCEPT;
executed 82100 times by 1 test: goto yyacceptlab;
Executed by:
  • Self test
82100
400 }-
401 | error '\n'-
402 {-
403 /* Error during parsing. Return NULL command. */-
404 global_command = (COMMAND *)NULL;-
405 eof_encountered = 0;-
406 /* discard_parser_constructs (1); */-
407 if (interactive && parse_and_execute_level == 0)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
parse_and_execute_level == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-22
408 {-
409 YYACCEPT;
never executed: goto yyacceptlab;
0
410 }-
411 else-
412 {-
413 YYABORT;
executed 22 times by 1 test: goto yyabortlab;
Executed by:
  • Self test
22
414 }-
415 }-
416 | error yacc_EOF-
417 {-
418 /* EOF after an error. Do ignoreeof or not. Really-
419 only interesting in non-interactive shells */-
420 global_command = (COMMAND *)NULL;-
421 last_command_exit_value = 1;-
422 handle_eof_input_unit ();-
423 if (interactive && parse_and_execute_level == 0)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
parse_and_execute_level == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
424 {-
425 YYACCEPT;
never executed: goto yyacceptlab;
0
426 }-
427 else-
428 {-
429 YYABORT;
executed 2 times by 1 test: goto yyabortlab;
Executed by:
  • Self test
2
430 }-
431 }-
432 | yacc_EOF-
433 {-
434 /* Case of EOF seen by itself. Do ignoreeof or-
435 not. */-
436 global_command = (COMMAND *)NULL;-
437 handle_eof_input_unit ();-
438 YYACCEPT;
executed 1290 times by 1 test: goto yyacceptlab;
Executed by:
  • Self test
1290
439 }-
440 ;-
441-
442word_list: WORD-
443 { $$ = make_word_list ($1, (WORD_LIST *)NULL); }-
444 | word_list WORD-
445 { $$ = make_word_list ($2, $1); }-
446 ;-
447-
448redirection: '>' WORD-
449 {-
450 source.dest = 1;-
451 redir.filename = $2;-
452 $$ = make_redirection (source, r_output_direction, redir, 0);-
453 }-
454 | '<' WORD-
455 {-
456 source.dest = 0;-
457 redir.filename = $2;-
458 $$ = make_redirection (source, r_input_direction, redir, 0);-
459 }-
460 | NUMBER '>' WORD-
461 {-
462 source.dest = $1;-
463 redir.filename = $3;-
464 $$ = make_redirection (source, r_output_direction, redir, 0);-
465 }-
466 | NUMBER '<' WORD-
467 {-
468 source.dest = $1;-
469 redir.filename = $3;-
470 $$ = make_redirection (source, r_input_direction, redir, 0);-
471 }-
472 | REDIR_WORD '>' WORD-
473 {-
474 source.filename = $1;-
475 redir.filename = $3;-
476 $$ = make_redirection (source, r_output_direction, redir, REDIR_VARASSIGN);-
477 }-
478 | REDIR_WORD '<' WORD-
479 {-
480 source.filename = $1;-
481 redir.filename = $3;-
482 $$ = make_redirection (source, r_input_direction, redir, REDIR_VARASSIGN);-
483 }-
484 | GREATER_GREATER WORD-
485 {-
486 source.dest = 1;-
487 redir.filename = $2;-
488 $$ = make_redirection (source, r_appending_to, redir, 0);-
489 }-
490 | NUMBER GREATER_GREATER WORD-
491 {-
492 source.dest = $1;-
493 redir.filename = $3;-
494 $$ = make_redirection (source, r_appending_to, redir, 0);-
495 }-
496 | REDIR_WORD GREATER_GREATER WORD-
497 {-
498 source.filename = $1;-
499 redir.filename = $3;-
500 $$ = make_redirection (source, r_appending_to, redir, REDIR_VARASSIGN);-
501 }-
502 | GREATER_BAR WORD-
503 {-
504 source.dest = 1;-
505 redir.filename = $2;-
506 $$ = make_redirection (source, r_output_force, redir, 0);-
507 }-
508 | NUMBER GREATER_BAR WORD-
509 {-
510 source.dest = $1;-
511 redir.filename = $3;-
512 $$ = make_redirection (source, r_output_force, redir, 0);-
513 }-
514 | REDIR_WORD GREATER_BAR WORD-
515 {-
516 source.filename = $1;-
517 redir.filename = $3;-
518 $$ = make_redirection (source, r_output_force, redir, REDIR_VARASSIGN);-
519 }-
520 | LESS_GREATER WORD-
521 {-
522 source.dest = 0;-
523 redir.filename = $2;-
524 $$ = make_redirection (source, r_input_output, redir, 0);-
525 }-
526 | NUMBER LESS_GREATER WORD-
527 {-
528 source.dest = $1;-
529 redir.filename = $3;-
530 $$ = make_redirection (source, r_input_output, redir, 0);-
531 }-
532 | REDIR_WORD LESS_GREATER WORD-
533 {-
534 source.filename = $1;-
535 redir.filename = $3;-
536 $$ = make_redirection (source, r_input_output, redir, REDIR_VARASSIGN);-
537 }-
538 | LESS_LESS WORD-
539 {-
540 source.dest = 0;-
541 redir.filename = $2;-
542 $$ = make_redirection (source, r_reading_until, redir, 0);-
543 push_heredoc ($$);-
544 }-
545 | NUMBER LESS_LESS WORD-
546 {-
547 source.dest = $1;-
548 redir.filename = $3;-
549 $$ = make_redirection (source, r_reading_until, redir, 0);-
550 push_heredoc ($$);-
551 }-
552 | REDIR_WORD LESS_LESS WORD-
553 {-
554 source.filename = $1;-
555 redir.filename = $3;-
556 $$ = make_redirection (source, r_reading_until, redir, REDIR_VARASSIGN);-
557 push_heredoc ($$);-
558 }-
559 | LESS_LESS_MINUS WORD-
560 {-
561 source.dest = 0;-
562 redir.filename = $2;-
563 $$ = make_redirection (source, r_deblank_reading_until, redir, 0);-
564 push_heredoc ($$);-
565 }-
566 | NUMBER LESS_LESS_MINUS WORD-
567 {-
568 source.dest = $1;-
569 redir.filename = $3;-
570 $$ = make_redirection (source, r_deblank_reading_until, redir, 0);-
571 push_heredoc ($$);-
572 }-
573 | REDIR_WORD LESS_LESS_MINUS WORD-
574 {-
575 source.filename = $1;-
576 redir.filename = $3;-
577 $$ = make_redirection (source, r_deblank_reading_until, redir, REDIR_VARASSIGN);-
578 push_heredoc ($$);-
579 }-
580 | LESS_LESS_LESS WORD-
581 {-
582 source.dest = 0;-
583 redir.filename = $2;-
584 $$ = make_redirection (source, r_reading_string, redir, 0);-
585 }-
586 | NUMBER LESS_LESS_LESS WORD-
587 {-
588 source.dest = $1;-
589 redir.filename = $3;-
590 $$ = make_redirection (source, r_reading_string, redir, 0);-
591 }-
592 | REDIR_WORD LESS_LESS_LESS WORD-
593 {-
594 source.filename = $1;-
595 redir.filename = $3;-
596 $$ = make_redirection (source, r_reading_string, redir, REDIR_VARASSIGN);-
597 }-
598 | LESS_AND NUMBER-
599 {-
600 source.dest = 0;-
601 redir.dest = $2;-
602 $$ = make_redirection (source, r_duplicating_input, redir, 0);-
603 }-
604 | NUMBER LESS_AND NUMBER-
605 {-
606 source.dest = $1;-
607 redir.dest = $3;-
608 $$ = make_redirection (source, r_duplicating_input, redir, 0);-
609 }-
610 | REDIR_WORD LESS_AND NUMBER-
611 {-
612 source.filename = $1;-
613 redir.dest = $3;-
614 $$ = make_redirection (source, r_duplicating_input, redir, REDIR_VARASSIGN);-
615 }-
616 | GREATER_AND NUMBER-
617 {-
618 source.dest = 1;-
619 redir.dest = $2;-
620 $$ = make_redirection (source, r_duplicating_output, redir, 0);-
621 }-
622 | NUMBER GREATER_AND NUMBER-
623 {-
624 source.dest = $1;-
625 redir.dest = $3;-
626 $$ = make_redirection (source, r_duplicating_output, redir, 0);-
627 }-
628 | REDIR_WORD GREATER_AND NUMBER-
629 {-
630 source.filename = $1;-
631 redir.dest = $3;-
632 $$ = make_redirection (source, r_duplicating_output, redir, REDIR_VARASSIGN);-
633 }-
634 | LESS_AND WORD-
635 {-
636 source.dest = 0;-
637 redir.filename = $2;-
638 $$ = make_redirection (source, r_duplicating_input_word, redir, 0);-
639 }-
640 | NUMBER LESS_AND WORD-
641 {-
642 source.dest = $1;-
643 redir.filename = $3;-
644 $$ = make_redirection (source, r_duplicating_input_word, redir, 0);-
645 }-
646 | REDIR_WORD LESS_AND WORD-
647 {-
648 source.filename = $1;-
649 redir.filename = $3;-
650 $$ = make_redirection (source, r_duplicating_input_word, redir, REDIR_VARASSIGN);-
651 }-
652 | GREATER_AND WORD-
653 {-
654 source.dest = 1;-
655 redir.filename = $2;-
656 $$ = make_redirection (source, r_duplicating_output_word, redir, 0);-
657 }-
658 | NUMBER GREATER_AND WORD-
659 {-
660 source.dest = $1;-
661 redir.filename = $3;-
662 $$ = make_redirection (source, r_duplicating_output_word, redir, 0);-
663 }-
664 | REDIR_WORD GREATER_AND WORD-
665 {-
666 source.filename = $1;-
667 redir.filename = $3;-
668 $$ = make_redirection (source, r_duplicating_output_word, redir, REDIR_VARASSIGN);-
669 }-
670 | GREATER_AND '-'-
671 {-
672 source.dest = 1;-
673 redir.dest = 0;-
674 $$ = make_redirection (source, r_close_this, redir, 0);-
675 }-
676 | NUMBER GREATER_AND '-'-
677 {-
678 source.dest = $1;-
679 redir.dest = 0;-
680 $$ = make_redirection (source, r_close_this, redir, 0);-
681 }-
682 | REDIR_WORD GREATER_AND '-'-
683 {-
684 source.filename = $1;-
685 redir.dest = 0;-
686 $$ = make_redirection (source, r_close_this, redir, REDIR_VARASSIGN);-
687 }-
688 | LESS_AND '-'-
689 {-
690 source.dest = 0;-
691 redir.dest = 0;-
692 $$ = make_redirection (source, r_close_this, redir, 0);-
693 }-
694 | NUMBER LESS_AND '-'-
695 {-
696 source.dest = $1;-
697 redir.dest = 0;-
698 $$ = make_redirection (source, r_close_this, redir, 0);-
699 }-
700 | REDIR_WORD LESS_AND '-'-
701 {-
702 source.filename = $1;-
703 redir.dest = 0;-
704 $$ = make_redirection (source, r_close_this, redir, REDIR_VARASSIGN);-
705 }-
706 | AND_GREATER WORD-
707 {-
708 source.dest = 1;-
709 redir.filename = $2;-
710 $$ = make_redirection (source, r_err_and_out, redir, 0);-
711 }-
712 | AND_GREATER_GREATER WORD-
713 {-
714 source.dest = 1;-
715 redir.filename = $2;-
716 $$ = make_redirection (source, r_append_err_and_out, redir, 0);-
717 }-
718 ;-
719-
720simple_command_element: WORD-
721 { $$.word = $1; $$.redirect = 0; }-
722 | ASSIGNMENT_WORD-
723 { $$.word = $1; $$.redirect = 0; }-
724 | redirection-
725 { $$.redirect = $1; $$.word = 0; }-
726 ;-
727-
728redirection_list: redirection-
729 {-
730 $$ = $1;-
731 }-
732 | redirection_list redirection-
733 {-
734 register REDIRECT *t;-
735-
736 for (t = $1; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
0-11
737 ;
never executed: ;
0
738 t->next = $2;-
739 $$ = $1;-
740 }-
741 ;-
742-
743simple_command: simple_command_element-
744 { $$ = make_simple_command ($1, (COMMAND *)NULL); }-
745 | simple_command simple_command_element-
746 { $$ = make_simple_command ($2, $1); }-
747 ;-
748-
749command: simple_command-
750 { $$ = clean_simple_command ($1); }-
751 | shell_command-
752 { $$ = $1; }-
753 | shell_command redirection_list-
754 {-
755 COMMAND *tc;-
756-
757 tc = $1;-
758 if (tc && tc->redirects)
tcDescription
TRUEevaluated 3093 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tc->redirectsDescription
TRUEnever evaluated
FALSEevaluated 3093 times by 1 test
Evaluated by:
  • Self test
0-3093
759 {-
760 register REDIRECT *t;-
761 for (t = tc->redirects; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
762 ;
never executed: ;
0
763 t->next = $2;-
764 }
never executed: end of block
0
765 else if (tc)
tcDescription
TRUEevaluated 3093 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3093
766 tc->redirects = $2;
executed 3093 times by 1 test: tc->redirects = (yyvsp[0].redirect);
Executed by:
  • Self test
3093
767 $$ = $1;-
768 }-
769 | function_def-
770 { $$ = $1; }-
771 | coproc-
772 { $$ = $1; }-
773 ;-
774-
775shell_command: for_command-
776 { $$ = $1; }-
777 | case_command-
778 { $$ = $1; }-
779 | WHILE compound_list DO compound_list DONE-
780 { $$ = make_while_command ($2, $4); }-
781 | UNTIL compound_list DO compound_list DONE-
782 { $$ = make_until_command ($2, $4); }-
783 | select_command-
784 { $$ = $1; }-
785 | if_command-
786 { $$ = $1; }-
787 | subshell-
788 { $$ = $1; }-
789 | group_command-
790 { $$ = $1; }-
791 | arith_command-
792 { $$ = $1; }-
793 | cond_command-
794 { $$ = $1; }-
795 | arith_for_command-
796 { $$ = $1; }-
797 ;-
798-
799for_command: FOR WORD newline_list DO compound_list DONE-
800 {-
801 $$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);-
802 if (word_top > 0) word_top--;
executed 1 time by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
803 }-
804 | FOR WORD newline_list '{' compound_list '}'-
805 {-
806 $$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);-
807 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
808 }-
809 | FOR WORD ';' newline_list DO compound_list DONE-
810 {-
811 $$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);-
812 if (word_top > 0) word_top--;
executed 1 time by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1
813 }-
814 | FOR WORD ';' newline_list '{' compound_list '}'-
815 {-
816 $$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);-
817 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
818 }-
819 | FOR WORD newline_list IN word_list list_terminator newline_list DO compound_list DONE-
820 {-
821 $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);-
822 if (word_top > 0) word_top--;
executed 23112 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 23112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2337 times by 1 test
Evaluated by:
  • Self test
2337-23112
823 }-
824 | FOR WORD newline_list IN word_list list_terminator newline_list '{' compound_list '}'-
825 {-
826 $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);-
827 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
828 }-
829 | FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE-
830 {-
831 $$ = make_for_command ($2, (WORD_LIST *)NULL, $8, word_lineno[word_top]);-
832 if (word_top > 0) word_top--;
executed 128 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
72-128
833 }-
834 | FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}'-
835 {-
836 $$ = make_for_command ($2, (WORD_LIST *)NULL, $8, word_lineno[word_top]);-
837 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
838 }-
839 ;-
840-
841arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE-
842 {-
843 $$ = make_arith_for_command ($2, $6, arith_for_lineno);-
844 if ($$ == 0) YYERROR;
executed 2 times by 1 test: goto yyerrorlab;
Executed by:
  • Self test
(yyval.command) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2237 times by 1 test
Evaluated by:
  • Self test
2-2237
845 if (word_top > 0) word_top--;
executed 4 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2233 times by 1 test
Evaluated by:
  • Self test
4-2233
846 }-
847 | FOR ARITH_FOR_EXPRS list_terminator newline_list '{' compound_list '}'-
848 {-
849 $$ = make_arith_for_command ($2, $6, arith_for_lineno);-
850 if ($$ == 0) YYERROR;
never executed: goto yyerrorlab;
(yyval.command) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
851 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
852 }-
853 | FOR ARITH_FOR_EXPRS DO compound_list DONE-
854 {-
855 $$ = make_arith_for_command ($2, $4, arith_for_lineno);-
856 if ($$ == 0) YYERROR;
never executed: goto yyerrorlab;
(yyval.command) == 0Description
TRUEnever evaluated
FALSEevaluated 201 times by 1 test
Evaluated by:
  • Self test
0-201
857 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEevaluated 201 times by 1 test
Evaluated by:
  • Self test
0-201
858 }-
859 | FOR ARITH_FOR_EXPRS '{' compound_list '}'-
860 {-
861 $$ = make_arith_for_command ($2, $4, arith_for_lineno);-
862 if ($$ == 0) YYERROR;
never executed: goto yyerrorlab;
(yyval.command) == 0Description
TRUEnever evaluated
FALSEevaluated 201 times by 1 test
Evaluated by:
  • Self test
0-201
863 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEevaluated 201 times by 1 test
Evaluated by:
  • Self test
0-201
864 }-
865 ;-
866-
867select_command: SELECT WORD newline_list DO list DONE-
868 {-
869 $$ = make_select_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);-
870 if (word_top > 0) word_top--;
executed 1 time by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
871 }-
872 | SELECT WORD newline_list '{' list '}'-
873 {-
874 $$ = make_select_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);-
875 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
876 }-
877 | SELECT WORD ';' newline_list DO list DONE-
878 {-
879 $$ = make_select_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);-
880 if (word_top > 0) word_top--;
executed 2 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
881 }-
882 | SELECT WORD ';' newline_list '{' list '}'-
883 {-
884 $$ = make_select_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);-
885 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
886 }-
887 | SELECT WORD newline_list IN word_list list_terminator newline_list DO list DONE-
888 {-
889 $$ = make_select_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);-
890 if (word_top > 0) word_top--;
executed 6 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6
891 }-
892 | SELECT WORD newline_list IN word_list list_terminator newline_list '{' list '}'-
893 {-
894 $$ = make_select_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);-
895 if (word_top > 0) word_top--;
never executed: word_top--;
word_top > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
896 }-
897 ;-
898-
899case_command: CASE WORD newline_list IN newline_list ESAC-
900 {-
901 $$ = make_case_command ($2, (PATTERN_LIST *)NULL, word_lineno[word_top]);-
902 if (word_top > 0) word_top--;
executed 1 time by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1
903 }-
904 | CASE WORD newline_list IN case_clause_sequence newline_list ESAC-
905 {-
906 $$ = make_case_command ($2, $5, word_lineno[word_top]);-
907 if (word_top > 0) word_top--;
executed 75309 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 75309 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 292 times by 1 test
Evaluated by:
  • Self test
292-75309
908 }-
909 | CASE WORD newline_list IN case_clause ESAC-
910 {-
911 $$ = make_case_command ($2, $5, word_lineno[word_top]);-
912 if (word_top > 0) word_top--;
executed 2450 times by 1 test: word_top--;
Executed by:
  • Self test
word_top > 0Description
TRUEevaluated 2450 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
57-2450
913 }-
914 ;-
915-
916function_def: WORD '(' ')' newline_list function_body-
917 { $$ = make_function_def ($1, $5, function_dstart, function_bstart); }-
918-
919 | FUNCTION WORD '(' ')' newline_list function_body-
920 { $$ = make_function_def ($2, $6, function_dstart, function_bstart); }-
921-
922 | FUNCTION WORD newline_list function_body-
923 { $$ = make_function_def ($2, $4, function_dstart, function_bstart); }-
924 ;-
925-
926function_body: shell_command-
927 { $$ = $1; }-
928 | shell_command redirection_list-
929 {-
930 COMMAND *tc;-
931-
932 tc = $1;-
933 /* According to Posix.2 3.9.5, redirections-
934 specified after the body of a function should-
935 be attached to the function and performed when-
936 the function is executed, not as part of the-
937 function definition command. */-
938 /* XXX - I don't think it matters, but we might-
939 want to change this in the future to avoid-
940 problems differentiating between a function-
941 definition with a redirection and a function-
942 definition containing a single command with a-
943 redirection. The two are semantically equivalent,-
944 though -- the only difference is in how the-
945 command printing code displays the redirections. */-
946 if (tc && tc->redirects)
tcDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tc->redirectsDescription
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
0-31
947 {-
948 register REDIRECT *t;-
949 for (t = tc->redirects; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
950 ;
never executed: ;
0
951 t->next = $2;-
952 }
never executed: end of block
0
953 else if (tc)
tcDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-31
954 tc->redirects = $2;
executed 31 times by 1 test: tc->redirects = (yyvsp[0].redirect);
Executed by:
  • Self test
31
955 $$ = $1;-
956 }-
957 ;-
958-
959subshell: '(' compound_list ')'-
960 {-
961 $$ = make_subshell_command ($2);-
962 $$->flags |= CMD_WANT_SUBSHELL;-
963 }-
964 ;-
965-
966coproc: COPROC shell_command-
967 {-
968 $$ = make_coproc_command ("COPROC", $2);-
969 $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;-
970 }-
971 | COPROC shell_command redirection_list-
972 {-
973 COMMAND *tc;-
974-
975 tc = $2;-
976 if (tc && tc->redirects)
tcDescription
TRUEnever evaluated
FALSEnever evaluated
tc->redirectsDescription
TRUEnever evaluated
FALSEnever evaluated
0
977 {-
978 register REDIRECT *t;-
979 for (t = tc->redirects; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
980 ;
never executed: ;
0
981 t->next = $3;-
982 }
never executed: end of block
0
983 else if (tc)
tcDescription
TRUEnever evaluated
FALSEnever evaluated
0
984 tc->redirects = $3;
never executed: tc->redirects = (yyvsp[0].redirect);
0
985 $$ = make_coproc_command ("COPROC", $2);-
986 $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;-
987 }-
988 | COPROC WORD shell_command-
989 {-
990 $$ = make_coproc_command ($2->word, $3);-
991 $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;-
992 }-
993 | COPROC WORD shell_command redirection_list-
994 {-
995 COMMAND *tc;-
996-
997 tc = $3;-
998 if (tc && tc->redirects)
tcDescription
TRUEnever evaluated
FALSEnever evaluated
tc->redirectsDescription
TRUEnever evaluated
FALSEnever evaluated
0
999 {-
1000 register REDIRECT *t;-
1001 for (t = tc->redirects; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1002 ;
never executed: ;
0
1003 t->next = $4;-
1004 }
never executed: end of block
0
1005 else if (tc)
tcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1006 tc->redirects = $4;
never executed: tc->redirects = (yyvsp[0].redirect);
0
1007 $$ = make_coproc_command ($2->word, $3);-
1008 $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;-
1009 }-
1010 | COPROC simple_command-
1011 {-
1012 $$ = make_coproc_command ("COPROC", clean_simple_command ($2));-
1013 $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;-
1014 }-
1015 ;-
1016-
1017if_command: IF compound_list THEN compound_list FI-
1018 { $$ = make_if_command ($2, $4, (COMMAND *)NULL); }-
1019 | IF compound_list THEN compound_list ELSE compound_list FI-
1020 { $$ = make_if_command ($2, $4, $6); }-
1021 | IF compound_list THEN compound_list elif_clause FI-
1022 { $$ = make_if_command ($2, $4, $5); }-
1023 ;-
1024-
1025-
1026group_command: '{' compound_list '}'-
1027 { $$ = make_group_command ($2); }-
1028 ;-
1029-
1030arith_command: ARITH_CMD-
1031 { $$ = make_arith_command ($1); }-
1032 ;-
1033-
1034cond_command: COND_START COND_CMD COND_END-
1035 { $$ = $2; }-
1036 ; -
1037-
1038elif_clause: ELIF compound_list THEN compound_list-
1039 { $$ = make_if_command ($2, $4, (COMMAND *)NULL); }-
1040 | ELIF compound_list THEN compound_list ELSE compound_list-
1041 { $$ = make_if_command ($2, $4, $6); }-
1042 | ELIF compound_list THEN compound_list elif_clause-
1043 { $$ = make_if_command ($2, $4, $5); }-
1044 ;-
1045-
1046case_clause: pattern_list-
1047 | case_clause_sequence pattern_list-
1048 { $2->next = $1; $$ = $2; }-
1049 ;-
1050-
1051pattern_list: newline_list pattern ')' compound_list-
1052 { $$ = make_pattern_list ($2, $4); }-
1053 | newline_list pattern ')' newline_list-
1054 { $$ = make_pattern_list ($2, (COMMAND *)NULL); }-
1055 | newline_list '(' pattern ')' compound_list-
1056 { $$ = make_pattern_list ($3, $5); }-
1057 | newline_list '(' pattern ')' newline_list-
1058 { $$ = make_pattern_list ($3, (COMMAND *)NULL); }-
1059 ;-
1060-
1061case_clause_sequence: pattern_list SEMI_SEMI-
1062 { $$ = $1; }-
1063 | case_clause_sequence pattern_list SEMI_SEMI-
1064 { $2->next = $1; $$ = $2; }-
1065 | pattern_list SEMI_AND-
1066 { $1->flags |= CASEPAT_FALLTHROUGH; $$ = $1; }-
1067 | case_clause_sequence pattern_list SEMI_AND-
1068 { $2->flags |= CASEPAT_FALLTHROUGH; $2->next = $1; $$ = $2; }-
1069 | pattern_list SEMI_SEMI_AND-
1070 { $1->flags |= CASEPAT_TESTNEXT; $$ = $1; }-
1071 | case_clause_sequence pattern_list SEMI_SEMI_AND-
1072 { $2->flags |= CASEPAT_TESTNEXT; $2->next = $1; $$ = $2; } -
1073 ;-
1074-
1075pattern: WORD-
1076 { $$ = make_word_list ($1, (WORD_LIST *)NULL); }-
1077 | pattern '|' WORD-
1078 { $$ = make_word_list ($3, $1); }-
1079 ;-
1080-
1081/* A list allows leading or trailing newlines and-
1082 newlines as operators (equivalent to semicolons).-
1083 It must end with a newline or semicolon.-
1084 Lists are used within commands such as if, for, while. */-
1085-
1086list: newline_list list0-
1087 {-
1088 $$ = $2;-
1089 if (need_here_doc)
need_here_docDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 95383 times by 1 test
Evaluated by:
  • Self test
2-95383
1090 gather_here_documents ();
executed 2 times by 1 test: gather_here_documents ();
Executed by:
  • Self test
2
1091 }-
1092 ;-
1093-
1094compound_list: list-
1095 | newline_list list1-
1096 {-
1097 $$ = $2;-
1098 }-
1099 ;-
1100-
1101list0: list1 '\n' newline_list-
1102 | list1 '&' newline_list-
1103 {-
1104 if ($1->type == cm_connection)
(yyvsp[-2].com... cm_connectionDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
14-24
1105 $$ = connect_async_list ($1, (COMMAND *)NULL, '&');
executed 14 times by 1 test: (yyval.command) = connect_async_list ((yyvsp[-2].command), (COMMAND *) ((void *)0) , '&');
Executed by:
  • Self test
14
1106 else-
1107 $$ = command_connect ($1, (COMMAND *)NULL, '&');
executed 24 times by 1 test: (yyval.command) = command_connect ((yyvsp[-2].command), (COMMAND *) ((void *)0) , '&');
Executed by:
  • Self test
24
1108 }-
1109 | list1 ';' newline_list-
1110-
1111 ;-
1112-
1113list1: list1 AND_AND newline_list list1-
1114 { $$ = command_connect ($1, $4, AND_AND); }-
1115 | list1 OR_OR newline_list list1-
1116 { $$ = command_connect ($1, $4, OR_OR); }-
1117 | list1 '&' newline_list list1-
1118 {-
1119 if ($1->type == cm_connection)
(yyvsp[-3].com... cm_connectionDescription
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 92 times by 1 test
Evaluated by:
  • Self test
39-92
1120 $$ = connect_async_list ($1, $4, '&');
executed 39 times by 1 test: (yyval.command) = connect_async_list ((yyvsp[-3].command), (yyvsp[0].command), '&');
Executed by:
  • Self test
39
1121 else-
1122 $$ = command_connect ($1, $4, '&');
executed 92 times by 1 test: (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), '&');
Executed by:
  • Self test
92
1123 }-
1124 | list1 ';' newline_list list1-
1125 { $$ = command_connect ($1, $4, ';'); }-
1126 | list1 '\n' newline_list list1-
1127 { $$ = command_connect ($1, $4, ';'); }-
1128 | pipeline_command-
1129 { $$ = $1; }-
1130 ;-
1131-
1132simple_list_terminator: '\n'-
1133 | yacc_EOF-
1134 ;-
1135-
1136list_terminator:'\n'-
1137 { $$ = '\n'; }-
1138 | ';'-
1139 { $$ = ';'; }-
1140 | yacc_EOF-
1141 { $$ = yacc_EOF; }-
1142 ;-
1143-
1144newline_list:-
1145 | newline_list '\n'-
1146 ;-
1147-
1148/* A simple_list is a list that contains no significant newlines-
1149 and no leading or trailing newlines. Newlines are allowed-
1150 only following operators, where they are not significant.-
1151-
1152 This is what an inputunit consists of. */-
1153-
1154simple_list: simple_list1-
1155 {-
1156 $$ = $1;-
1157 if (need_here_doc)
need_here_docDescription
TRUEnever evaluated
FALSEevaluated 824352 times by 1 test
Evaluated by:
  • Self test
0-824352
1158 gather_here_documents ();
never executed: gather_here_documents ();
0
1159 if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
(parser_state & 0x000040)Description
TRUEevaluated 705161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 119191 times by 1 test
Evaluated by:
  • Self test
current_token ...hell_eof_tokenDescription
TRUEevaluated 704323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 838 times by 1 test
Evaluated by:
  • Self test
838-705161
1160 {-
1161 global_command = $1;-
1162 eof_encountered = 0;-
1163 rewind_input_string ();-
1164 YYACCEPT;
executed 704323 times by 1 test: goto yyacceptlab;
Executed by:
  • Self test
704323
1165 }-
1166 }-
1167 | simple_list1 '&'-
1168 {-
1169 if ($1->type == cm_connection)
(yyvsp[-1].com... cm_connectionDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115 times by 1 test
Evaluated by:
  • Self test
9-115
1170 $$ = connect_async_list ($1, (COMMAND *)NULL, '&');
executed 9 times by 1 test: (yyval.command) = connect_async_list ((yyvsp[-1].command), (COMMAND *) ((void *)0) , '&');
Executed by:
  • Self test
9
1171 else-
1172 $$ = command_connect ($1, (COMMAND *)NULL, '&');
executed 115 times by 1 test: (yyval.command) = command_connect ((yyvsp[-1].command), (COMMAND *) ((void *)0) , '&');
Executed by:
  • Self test
115
1173 if (need_here_doc)
need_here_docDescription
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • Self test
0-124
1174 gather_here_documents ();
never executed: gather_here_documents ();
0
1175 if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
(parser_state & 0x000040)Description
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • Self test
current_token ...hell_eof_tokenDescription
TRUEnever evaluated
FALSEnever evaluated
0-124
1176 {-
1177 global_command = $1;-
1178 eof_encountered = 0;-
1179 rewind_input_string ();-
1180 YYACCEPT;
never executed: goto yyacceptlab;
0
1181 }-
1182 }-
1183 | simple_list1 ';'-
1184 {-
1185 $$ = $1;-
1186 if (need_here_doc)
need_here_docDescription
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
0-49
1187 gather_here_documents ();
never executed: gather_here_documents ();
0
1188 if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
(parser_state & 0x000040)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
current_token ...hell_eof_tokenDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-44
1189 {-
1190 global_command = $1;-
1191 eof_encountered = 0;-
1192 rewind_input_string ();-
1193 YYACCEPT;
executed 5 times by 1 test: goto yyacceptlab;
Executed by:
  • Self test
5
1194 }-
1195 }-
1196 ;-
1197-
1198simple_list1: simple_list1 AND_AND newline_list simple_list1-
1199 { $$ = command_connect ($1, $4, AND_AND); }-
1200 | simple_list1 OR_OR newline_list simple_list1-
1201 { $$ = command_connect ($1, $4, OR_OR); }-
1202 | simple_list1 '&' simple_list1-
1203 {-
1204 if ($1->type == cm_connection)
(yyvsp[-2].com... cm_connectionDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
1-15
1205 $$ = connect_async_list ($1, $3, '&');
executed 1 time by 1 test: (yyval.command) = connect_async_list ((yyvsp[-2].command), (yyvsp[0].command), '&');
Executed by:
  • Self test
1
1206 else-
1207 $$ = command_connect ($1, $3, '&');
executed 15 times by 1 test: (yyval.command) = command_connect ((yyvsp[-2].command), (yyvsp[0].command), '&');
Executed by:
  • Self test
15
1208 }-
1209 | simple_list1 ';' simple_list1-
1210 { $$ = command_connect ($1, $3, ';'); }-
1211-
1212 | pipeline_command-
1213 { $$ = $1; }-
1214 ;-
1215-
1216pipeline_command: pipeline-
1217 { $$ = $1; } -
1218 | BANG pipeline_command-
1219 {-
1220 if ($2)
(yyvsp[0].command)Description
TRUEevaluated 290 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-290
1221 $2->flags ^= CMD_INVERT_RETURN; /* toggle */
executed 290 times by 1 test: (yyvsp[0].command)->flags ^= 0x04;
Executed by:
  • Self test
290
1222 $$ = $2;-
1223 }-
1224 | timespec pipeline_command-
1225 {-
1226 if ($2)
(yyvsp[0].command)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14
1227 $2->flags |= $1;
executed 14 times by 1 test: (yyvsp[0].command)->flags |= (yyvsp[-1].number);
Executed by:
  • Self test
14
1228 $$ = $2;-
1229 }-
1230 | timespec list_terminator-
1231 {-
1232 ELEMENT x;-
1233-
1234 /* Boy, this is unclean. `time' by itself can-
1235 time a null command. We cheat and push a-
1236 newline back if the list_terminator was a newline-
1237 to avoid the double-newline problem (one to-
1238 terminate this, one to terminate the command) */-
1239 x.word = 0;-
1240 x.redirect = 0;-
1241 $$ = make_simple_command (x, (COMMAND *)NULL);-
1242 $$->flags |= $1;-
1243 /* XXX - let's cheat and push a newline back */-
1244 if ($2 == '\n')
(yyvsp[0].number) == '\n'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
1245 token_to_read = '\n';
executed 1 time by 1 test: token_to_read = '\n';
Executed by:
  • Self test
1
1246 else if ($2 == ';')
(yyvsp[0].number) == ';'Description
TRUEnever evaluated
FALSEnever evaluated
0
1247 token_to_read = ';';
never executed: token_to_read = ';';
0
1248 parser_state &= ~PST_REDIRLIST; /* make_simple_command sets this */-
1249 }-
1250 | BANG list_terminator-
1251 {-
1252 ELEMENT x;-
1253-
1254 /* This is just as unclean. Posix says that `!'-
1255 by itself should be equivalent to `false'.-
1256 We cheat and push a-
1257 newline back if the list_terminator was a newline-
1258 to avoid the double-newline problem (one to-
1259 terminate this, one to terminate the command) */-
1260 x.word = 0;-
1261 x.redirect = 0;-
1262 $$ = make_simple_command (x, (COMMAND *)NULL);-
1263 $$->flags |= CMD_INVERT_RETURN;-
1264 /* XXX - let's cheat and push a newline back */-
1265 if ($2 == '\n')
(yyvsp[0].number) == '\n'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
1266 token_to_read = '\n';
executed 4 times by 1 test: token_to_read = '\n';
Executed by:
  • Self test
4
1267 if ($2 == ';')
(yyvsp[0].number) == ';'Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-4
1268 token_to_read = ';';
never executed: token_to_read = ';';
0
1269 parser_state &= ~PST_REDIRLIST; /* make_simple_command sets this */-
1270 }-
1271 ;-
1272-
1273pipeline: pipeline '|' newline_list pipeline-
1274 { $$ = command_connect ($1, $4, '|'); }-
1275 | pipeline BAR_AND newline_list pipeline-
1276 {-
1277 /* Make cmd1 |& cmd2 equivalent to cmd1 2>&1 | cmd2 */-
1278 COMMAND *tc;-
1279 REDIRECTEE rd, sd;-
1280 REDIRECT *r;-
1281-
1282 tc = $1->type == cm_simple ? (COMMAND *)$1->value.Simple : $1;
(yyvsp[-3].com...e == cm_simpleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
1283 sd.dest = 2;-
1284 rd.dest = 1;-
1285 r = make_redirection (sd, r_duplicating_output, rd, 0);-
1286 if (tc->redirects)
tc->redirectsDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1287 {-
1288 register REDIRECT *t;-
1289 for (t = tc->redirects; t->next; t = t->next)
t->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1290 ;
never executed: ;
0
1291 t->next = r;-
1292 }
never executed: end of block
0
1293 else-
1294 tc->redirects = r;
executed 2 times by 1 test: tc->redirects = r;
Executed by:
  • Self test
2
1295-
1296 $$ = command_connect ($1, $4, '|');-
1297 }-
1298 | command-
1299 { $$ = $1; }-
1300 ;-
1301-
1302timespec: TIME-
1303 { $$ = CMD_TIME_PIPELINE; }-
1304 | TIME TIMEOPT-
1305 { $$ = CMD_TIME_PIPELINE|CMD_TIME_POSIX; }-
1306 | TIME TIMEOPT TIMEIGN-
1307 { $$ = CMD_TIME_PIPELINE|CMD_TIME_POSIX; }-
1308 ;-
1309%%-
1310-
1311/* Initial size to allocate for tokens, and the-
1312 amount to grow them by. */-
1313#define TOKEN_DEFAULT_INITIAL_SIZE 496-
1314#define TOKEN_DEFAULT_GROW_SIZE 512-
1315-
1316/* Should we call prompt_again? */-
1317#define SHOULD_PROMPT() \-
1318 (interactive && (bash_input.type == st_stdin || bash_input.type == st_stream))-
1319-
1320#if defined (ALIAS)-
1321# define expanding_alias() (pushed_string_list && pushed_string_list->expander)-
1322#else-
1323# define expanding_alias() 0-
1324#endif-
1325-
1326/* Global var is non-zero when end of file has been reached. */-
1327int EOF_Reached = 0;-
1328-
1329#ifdef DEBUG-
1330static void-
1331debug_parser (i)-
1332 int i;-
1333{-
1334#if YYDEBUG != 0-
1335 yydebug = i;-
1336 yyoutstream = stdout;-
1337 yyerrstream = stderr;-
1338#endif-
1339}
never executed: end of block
0
1340#endif-
1341-
1342/* yy_getc () returns the next available character from input or EOF.-
1343 yy_ungetc (c) makes `c' the next character to read.-
1344 init_yy_io (get, unget, type, location) makes the function GET the-
1345 installed function for getting the next character, makes UNGET the-
1346 installed function for un-getting a character, sets the type of stream-
1347 (either string or file) from TYPE, and makes LOCATION point to where-
1348 the input is coming from. */-
1349-
1350/* Unconditionally returns end-of-file. */-
1351int-
1352return_EOF ()-
1353{-
1354 return (EOF);
never executed: return ( (-1) );
0
1355}-
1356-
1357/* Variable containing the current get and unget functions.-
1358 See ./input.h for a clearer description. */-
1359BASH_INPUT bash_input;-
1360-
1361/* Set all of the fields in BASH_INPUT to NULL. Free bash_input.name if it-
1362 is non-null, avoiding a memory leak. */-
1363void-
1364initialize_bash_input ()-
1365{-
1366 bash_input.type = st_none;-
1367 FREE (bash_input.name);
executed 15 times by 1 test: sh_xfree((bash_input.name), "./parse.y", 1367);
Executed by:
  • Self test
bash_input.nameDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
15-5432
1368 bash_input.name = (char *)NULL;-
1369 bash_input.location.file = (FILE *)NULL;-
1370 bash_input.location.string = (char *)NULL;-
1371 bash_input.getter = (sh_cget_func_t *)NULL;-
1372 bash_input.ungetter = (sh_cunget_func_t *)NULL;-
1373}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
1374-
1375/* Set the contents of the current bash input stream from-
1376 GET, UNGET, TYPE, NAME, and LOCATION. */-
1377void-
1378init_yy_io (get, unget, type, name, location)-
1379 sh_cget_func_t *get;-
1380 sh_cunget_func_t *unget;-
1381 enum stream_type type;-
1382 const char *name;-
1383 INPUT_STREAM location;-
1384{-
1385 bash_input.type = type;-
1386 FREE (bash_input.name);
executed 725402 times by 1 test: sh_xfree((bash_input.name), "./parse.y", 1386);
Executed by:
  • Self test
bash_input.nameDescription
TRUEevaluated 725402 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 732379 times by 1 test
Evaluated by:
  • Self test
725402-732379
1387 bash_input.name = name ? savestring (name) : (char *)NULL;
nameDescription
TRUEevaluated 1457539 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 242 times by 1 test
Evaluated by:
  • Self test
242-1457539
1388-
1389 /* XXX */-
1390#if defined (CRAY)-
1391 memcpy((char *)&bash_input.location.string, (char *)&location.string, sizeof(location));-
1392#else-
1393 bash_input.location = location;-
1394#endif-
1395 bash_input.getter = get;-
1396 bash_input.ungetter = unget;-
1397}
executed 1457781 times by 1 test: end of block
Executed by:
  • Self test
1457781
1398-
1399char *-
1400yy_input_name ()-
1401{-
1402 return (bash_input.name ? bash_input.name : "stdin");
executed 91 times by 1 test: return (bash_input.name ? bash_input.name : "stdin");
Executed by:
  • Self test
91
1403}-
1404-
1405/* Call this to get the next character of input. */-
1406static int-
1407yy_getc ()-
1408{-
1409 return (*(bash_input.getter)) ();
executed 20807233 times by 1 test: return (*(bash_input.getter)) ();
Executed by:
  • Self test
20807233
1410}-
1411-
1412/* Call this to unget C. That is, to make C the next character-
1413 to be read. */-
1414static int-
1415yy_ungetc (c)-
1416 int c;-
1417{-
1418 return (*(bash_input.ungetter)) (c);
executed 1161 times by 1 test: return (*(bash_input.ungetter)) (c);
Executed by:
  • Self test
1161
1419}-
1420-
1421#if defined (BUFFERED_INPUT)-
1422#ifdef INCLUDE_UNUSED-
1423int-
1424input_file_descriptor ()-
1425{-
1426 switch (bash_input.type)-
1427 {-
1428 case st_stream:-
1429 return (fileno (bash_input.location.file));-
1430 case st_bstream:-
1431 return (bash_input.location.buffered_fd);-
1432 case st_stdin:-
1433 default:-
1434 return (fileno (stdin));-
1435 }-
1436}-
1437#endif-
1438#endif /* BUFFERED_INPUT */-
1439-
1440/* **************************************************************** */-
1441/* */-
1442/* Let input be read from readline (). */-
1443/* */-
1444/* **************************************************************** */-
1445-
1446#if defined (READLINE)-
1447char *current_readline_prompt = (char *)NULL;-
1448char *current_readline_line = (char *)NULL;-
1449int current_readline_line_index = 0;-
1450-
1451static int-
1452yy_readline_get ()-
1453{-
1454 SigHandler *old_sigint;-
1455 int line_len;-
1456 unsigned char c;-
1457-
1458 if (current_readline_line == 0)
current_readline_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1459 {-
1460 if (bash_readline_initialized == 0)
bash_readline_initialized == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1461 initialize_readline ();
never executed: initialize_readline ();
0
1462-
1463#if defined (JOB_CONTROL)-
1464 if (job_control)
job_controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
1465 give_terminal_to (shell_pgrp, 0);
never executed: give_terminal_to (shell_pgrp, 0);
0
1466#endif /* JOB_CONTROL */-
1467-
1468 old_sigint = IMPOSSIBLE_TRAP_HANDLER;-
1469 if (signal_is_ignored (SIGINT) == 0)
signal_is_ignored ( 2 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1470 {-
1471 /* interrupt_immediately++; */-
1472 old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler);-
1473 }
never executed: end of block
0
1474-
1475 sh_unset_nodelay_mode (fileno (rl_instream)); /* just in case */-
1476 current_readline_line = readline (current_readline_prompt ?-
1477 current_readline_prompt : "");-
1478-
1479 CHECK_TERMSIG;
never executed: termsig_handler (terminating_signal);
terminating_signalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1480 if (signal_is_ignored (SIGINT) == 0)
signal_is_ignored ( 2 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1481 {-
1482 /* interrupt_immediately--; */-
1483 if (old_sigint != IMPOSSIBLE_TRAP_HANDLER)
old_sigint != ...itialize_trapsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1484 set_signal_handler (SIGINT, old_sigint);
never executed: set_signal_handler ( 2 , old_sigint);
0
1485 }
never executed: end of block
0
1486-
1487#if 0-
1488 /* Reset the prompt to the decoded value of prompt_string_pointer. */-
1489 reset_readline_prompt ();-
1490#endif-
1491-
1492 if (current_readline_line == 0)
current_readline_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1493 return (EOF);
never executed: return ( (-1) );
0
1494-
1495 current_readline_line_index = 0;-
1496 line_len = strlen (current_readline_line);-
1497-
1498 current_readline_line = (char *)xrealloc (current_readline_line, 2 + line_len);-
1499 current_readline_line[line_len++] = '\n';-
1500 current_readline_line[line_len] = '\0';-
1501 }
never executed: end of block
0
1502-
1503 if (current_readline_line[current_readline_line_index] == 0)
current_readli...ne_index] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1504 {-
1505 free (current_readline_line);-
1506 current_readline_line = (char *)NULL;-
1507 return (yy_readline_get ());
never executed: return (yy_readline_get ());
0
1508 }-
1509 else-
1510 {-
1511 c = current_readline_line[current_readline_line_index++];-
1512 return (c);
never executed: return (c);
0
1513 }-
1514}-
1515-
1516static int-
1517yy_readline_unget (c)-
1518 int c;-
1519{-
1520 if (current_readline_line_index && current_readline_line)
current_readline_line_indexDescription
TRUEnever evaluated
FALSEnever evaluated
current_readline_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1521 current_readline_line[--current_readline_line_index] = c;
never executed: current_readline_line[--current_readline_line_index] = c;
0
1522 return (c);
never executed: return (c);
0
1523}-
1524-
1525void-
1526with_input_from_stdin ()-
1527{-
1528 INPUT_STREAM location;-
1529-
1530 if (bash_input.type != st_stdin && stream_on_stack (st_stdin) == 0)
bash_input.type != st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
stream_on_stac...st_stdin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1531 {-
1532 location.string = current_readline_line;-
1533 init_yy_io (yy_readline_get, yy_readline_unget,-
1534 st_stdin, "readline stdin", location);-
1535 }
never executed: end of block
0
1536}
never executed: end of block
0
1537-
1538#else /* !READLINE */-
1539-
1540void-
1541with_input_from_stdin ()-
1542{-
1543 with_input_from_stream (stdin, "stdin");-
1544}-
1545#endif /* !READLINE */-
1546-
1547/* **************************************************************** */-
1548/* */-
1549/* Let input come from STRING. STRING is zero terminated. */-
1550/* */-
1551/* **************************************************************** */-
1552-
1553static int-
1554yy_string_get ()-
1555{-
1556 register char *string;-
1557 register unsigned char c;-
1558-
1559 string = bash_input.location.string;-
1560-
1561 /* If the string doesn't exist, or is empty, EOF found. */-
1562 if (string && *string)
stringDescription
TRUEevaluated 7578364 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*stringDescription
TRUEevaluated 6852790 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 725574 times by 1 test
Evaluated by:
  • Self test
0-7578364
1563 {-
1564 c = *string++;-
1565 bash_input.location.string = string;-
1566 return (c);
executed 6852790 times by 1 test: return (c);
Executed by:
  • Self test
6852790
1567 }-
1568 else-
1569 return (EOF);
executed 725574 times by 1 test: return ( (-1) );
Executed by:
  • Self test
725574
1570}-
1571-
1572static int-
1573yy_string_unget (c)-
1574 int c;-
1575{-
1576 *(--bash_input.location.string) = c;-
1577 return (c);
executed 1 time by 1 test: return (c);
Executed by:
  • Self test
1
1578}-
1579-
1580void-
1581with_input_from_string (string, name)-
1582 char *string;-
1583 const char *name;-
1584{-
1585 INPUT_STREAM location;-
1586-
1587 location.string = string;-
1588 init_yy_io (yy_string_get, yy_string_unget, st_string, name, location);-
1589}
executed 727082 times by 1 test: end of block
Executed by:
  • Self test
727082
1590-
1591/* Count the number of characters we've consumed from bash_input.location.string-
1592 and read into shell_input_line, but have not returned from shell_getc.-
1593 That is the true input location. Rewind bash_input.location.string by-
1594 that number of characters, so it points to the last character actually-
1595 consumed by the parser. */-
1596static void-
1597rewind_input_string ()-
1598{-
1599 int xchars;-
1600-
1601 /* number of unconsumed characters in the input -- XXX need to take newlines-
1602 into account, e.g., $(...\n) */-
1603 xchars = shell_input_line_len - shell_input_line_index;-
1604 if (bash_input.location.string[-1] == '\n')
bash_input.loc...ng[-1] == '\n'Description
TRUEevaluated 119 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705170 times by 1 test
Evaluated by:
  • Self test
119-705170
1605 xchars++;
executed 119 times by 1 test: xchars++;
Executed by:
  • Self test
119
1606-
1607 /* XXX - how to reflect bash_input.location.string back to string passed to-
1608 parse_and_execute or xparse_dolparen? xparse_dolparen needs to know how-
1609 far into the string we parsed. parse_and_execute knows where bash_input.-
1610 location.string is, and how far from orig_string that is -- that's the-
1611 number of characters the command consumed. */-
1612-
1613 /* bash_input.location.string - xchars should be where we parsed to */-
1614 /* need to do more validation on xchars value for sanity -- test cases. */-
1615 bash_input.location.string -= xchars;-
1616}
executed 705289 times by 1 test: end of block
Executed by:
  • Self test
705289
1617-
1618/* **************************************************************** */-
1619/* */-
1620/* Let input come from STREAM. */-
1621/* */-
1622/* **************************************************************** */-
1623-
1624/* These two functions used to test the value of the HAVE_RESTARTABLE_SYSCALLS-
1625 define, and just use getc/ungetc if it was defined, but since bash-
1626 installs its signal handlers without the SA_RESTART flag, some signals-
1627 (like SIGCHLD, SIGWINCH, etc.) received during a read(2) will not cause-
1628 the read to be restarted. We need to restart it ourselves. */-
1629-
1630static int-
1631yy_stream_get ()-
1632{-
1633 int result;-
1634-
1635 result = EOF;-
1636 if (bash_input.location.file)
bash_input.location.fileDescription
TRUEnever evaluated
FALSEnever evaluated
0
1637 {-
1638 /* XXX - don't need terminate_immediately; getc_with_restart checks-
1639 for terminating signals itself if read returns < 0 */-
1640 result = getc_with_restart (bash_input.location.file);-
1641 }
never executed: end of block
0
1642 return (result);
never executed: return (result);
0
1643}-
1644-
1645static int-
1646yy_stream_unget (c)-
1647 int c;-
1648{-
1649 return (ungetc_with_restart (c, bash_input.location.file));
never executed: return (ungetc_with_restart (c, bash_input.location.file));
0
1650}-
1651-
1652void-
1653with_input_from_stream (stream, name)-
1654 FILE *stream;-
1655 const char *name;-
1656{-
1657 INPUT_STREAM location;-
1658-
1659 location.file = stream;-
1660 init_yy_io (yy_stream_get, yy_stream_unget, st_stream, name, location);-
1661}
never executed: end of block
0
1662-
1663typedef struct stream_saver {-
1664 struct stream_saver *next;-
1665 BASH_INPUT bash_input;-
1666 int line;-
1667#if defined (BUFFERED_INPUT)-
1668 BUFFERED_STREAM *bstream;-
1669#endif /* BUFFERED_INPUT */-
1670} STREAM_SAVER;-
1671-
1672/* The globally known line number. */-
1673int line_number = 0;-
1674-
1675/* The line number offset set by assigning to LINENO. Not currently used. */-
1676int line_number_base = 0;-
1677-
1678#if defined (COND_COMMAND)-
1679static int cond_lineno;-
1680static int cond_token;-
1681#endif-
1682-
1683STREAM_SAVER *stream_list = (STREAM_SAVER *)NULL;-
1684-
1685void-
1686push_stream (reset_lineno)-
1687 int reset_lineno;-
1688{-
1689 STREAM_SAVER *saver = (STREAM_SAVER *)xmalloc (sizeof (STREAM_SAVER));-
1690-
1691 xbcopy ((char *)&bash_input, (char *)&(saver->bash_input), sizeof (BASH_INPUT));-
1692-
1693#if defined (BUFFERED_INPUT)-
1694 saver->bstream = (BUFFERED_STREAM *)NULL;-
1695 /* If we have a buffered stream, clear out buffers[fd]. */-
1696 if (bash_input.type == st_bstream && bash_input.location.buffered_fd >= 0)
bash_input.type == st_bstreamDescription
TRUEevaluated 716135 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10947 times by 1 test
Evaluated by:
  • Self test
bash_input.loc...ffered_fd >= 0Description
TRUEevaluated 716135 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-716135
1697 saver->bstream = set_buffered_stream (bash_input.location.buffered_fd,
executed 716135 times by 1 test: saver->bstream = set_buffered_stream (bash_input.location.buffered_fd, (BUFFERED_STREAM *) ((void *)0) );
Executed by:
  • Self test
716135
1698 (BUFFERED_STREAM *)NULL);
executed 716135 times by 1 test: saver->bstream = set_buffered_stream (bash_input.location.buffered_fd, (BUFFERED_STREAM *) ((void *)0) );
Executed by:
  • Self test
716135
1699#endif /* BUFFERED_INPUT */-
1700-
1701 saver->line = line_number;-
1702 bash_input.name = (char *)NULL;-
1703 saver->next = stream_list;-
1704 stream_list = saver;-
1705 EOF_Reached = 0;-
1706 if (reset_lineno)
reset_linenoDescription
TRUEevaluated 1913 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 725169 times by 1 test
Evaluated by:
  • Self test
1913-725169
1707 line_number = 0;
executed 1913 times by 1 test: line_number = 0;
Executed by:
  • Self test
1913
1708}
executed 727082 times by 1 test: end of block
Executed by:
  • Self test
727082
1709-
1710void-
1711pop_stream ()-
1712{-
1713 if (!stream_list)
!stream_listDescription
TRUEnever evaluated
FALSEevaluated 725433 times by 1 test
Evaluated by:
  • Self test
0-725433
1714 EOF_Reached = 1;
never executed: EOF_Reached = 1;
0
1715 else-
1716 {-
1717 STREAM_SAVER *saver = stream_list;-
1718-
1719 EOF_Reached = 0;-
1720 stream_list = stream_list->next;-
1721-
1722 init_yy_io (saver->bash_input.getter,-
1723 saver->bash_input.ungetter,-
1724 saver->bash_input.type,-
1725 saver->bash_input.name,-
1726 saver->bash_input.location);-
1727-
1728#if defined (BUFFERED_INPUT)-
1729 /* If we have a buffered stream, restore buffers[fd]. */-
1730 /* If the input file descriptor was changed while this was on the-
1731 save stack, update the buffered fd to the new file descriptor and-
1732 re-establish the buffer <-> bash_input fd correspondence. */-
1733 if (bash_input.type == st_bstream && bash_input.location.buffered_fd >= 0)
bash_input.type == st_bstreamDescription
TRUEevaluated 716122 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9311 times by 1 test
Evaluated by:
  • Self test
bash_input.loc...ffered_fd >= 0Description
TRUEevaluated 716122 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-716122
1734 {-
1735 if (bash_input_fd_changed)
bash_input_fd_changedDescription
TRUEnever evaluated
FALSEevaluated 716122 times by 1 test
Evaluated by:
  • Self test
0-716122
1736 {-
1737 bash_input_fd_changed = 0;-
1738 if (default_buffered_input >= 0)
default_buffered_input >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1739 {-
1740 bash_input.location.buffered_fd = default_buffered_input;-
1741 saver->bstream->b_fd = default_buffered_input;-
1742 SET_CLOSE_ON_EXEC (default_buffered_input);-
1743 }
never executed: end of block
0
1744 }
never executed: end of block
0
1745 /* XXX could free buffered stream returned as result here. */-
1746 set_buffered_stream (bash_input.location.buffered_fd, saver->bstream);-
1747 }
executed 716122 times by 1 test: end of block
Executed by:
  • Self test
716122
1748#endif /* BUFFERED_INPUT */-
1749-
1750 line_number = saver->line;-
1751-
1752 FREE (saver->bash_input.name);
executed 725222 times by 1 test: sh_xfree((saver->bash_input.name), "./parse.y", 1752);
Executed by:
  • Self test
saver->bash_input.nameDescription
TRUEevaluated 725222 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 211 times by 1 test
Evaluated by:
  • Self test
211-725222
1753 free (saver);-
1754 }
executed 725433 times by 1 test: end of block
Executed by:
  • Self test
725433
1755}-
1756-
1757/* Return 1 if a stream of type TYPE is saved on the stack. */-
1758int-
1759stream_on_stack (type)-
1760 enum stream_type type;-
1761{-
1762 register STREAM_SAVER *s;-
1763-
1764 for (s = stream_list; s; s = s->next)
sDescription
TRUEnever evaluated
FALSEnever evaluated
0
1765 if (s->bash_input.type == type)
s->bash_input.type == typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1766 return 1;
never executed: return 1;
0
1767 return 0;
never executed: return 0;
0
1768}-
1769-
1770/* Save the current token state and return it in a malloced array. */-
1771int *-
1772save_token_state ()-
1773{-
1774 int *ret;-
1775-
1776 ret = (int *)xmalloc (4 * sizeof (int));-
1777 ret[0] = last_read_token;-
1778 ret[1] = token_before_that;-
1779 ret[2] = two_tokens_ago;-
1780 ret[3] = current_token;-
1781 return ret;
executed 707380 times by 1 test: return ret;
Executed by:
  • Self test
707380
1782}-
1783-
1784void-
1785restore_token_state (ts)-
1786 int *ts;-
1787{-
1788 if (ts == 0)
ts == 0Description
TRUEnever evaluated
FALSEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
0-707380
1789 return;
never executed: return;
0
1790 last_read_token = ts[0];-
1791 token_before_that = ts[1];-
1792 two_tokens_ago = ts[2];-
1793 current_token = ts[3];-
1794}
executed 707380 times by 1 test: end of block
Executed by:
  • Self test
707380
1795-
1796/*-
1797 * This is used to inhibit alias expansion and reserved word recognition-
1798 * inside case statement pattern lists. A `case statement pattern list' is:-
1799 *-
1800 * everything between the `in' in a `case word in' and the next ')'-
1801 * or `esac'-
1802 * everything between a `;;' and the next `)' or `esac'-
1803 */-
1804-
1805#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
1806-
1807#define END_OF_ALIAS 0-
1808-
1809/*-
1810 * Pseudo-global variables used in implementing token-wise alias expansion.-
1811 */-
1812-
1813/*-
1814 * Pushing and popping strings. This works together with shell_getc to-
1815 * implement alias expansion on a per-token basis.-
1816 */-
1817-
1818#define PSH_ALIAS 0x01-
1819#define PSH_DPAREN 0x02-
1820#define PSH_SOURCE 0x04-
1821-
1822typedef struct string_saver {-
1823 struct string_saver *next;-
1824 int expand_alias; /* Value to set expand_alias to when string is popped. */-
1825 char *saved_line;-
1826#if defined (ALIAS)-
1827 alias_t *expander; /* alias that caused this line to be pushed. */-
1828#endif-
1829 size_t saved_line_size, saved_line_index;-
1830 int saved_line_terminator;-
1831 int flags;-
1832} STRING_SAVER;-
1833-
1834STRING_SAVER *pushed_string_list = (STRING_SAVER *)NULL;-
1835-
1836/*-
1837 * Push the current shell_input_line onto a stack of such lines and make S-
1838 * the current input. Used when expanding aliases. EXPAND is used to set-
1839 * the value of expand_next_token when the string is popped, so that the-
1840 * word after the alias in the original line is handled correctly when the-
1841 * alias expands to multiple words. TOKEN is the token that was expanded-
1842 * into S; it is saved and used to prevent infinite recursive expansion.-
1843 */-
1844static void-
1845push_string (s, expand, ap)-
1846 char *s;-
1847 int expand;-
1848 alias_t *ap;-
1849{-
1850 STRING_SAVER *temp = (STRING_SAVER *)xmalloc (sizeof (STRING_SAVER));-
1851-
1852 temp->expand_alias = expand;-
1853 temp->saved_line = shell_input_line;-
1854 temp->saved_line_size = shell_input_line_size;-
1855 temp->saved_line_index = shell_input_line_index;-
1856 temp->saved_line_terminator = shell_input_line_terminator;-
1857 temp->flags = 0;-
1858#if defined (ALIAS)-
1859 temp->expander = ap;-
1860 if (ap)
apDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-82
1861 temp->flags = PSH_ALIAS;
executed 82 times by 1 test: temp->flags = 0x01;
Executed by:
  • Self test
82
1862#endif-
1863 temp->next = pushed_string_list;-
1864 pushed_string_list = temp;-
1865-
1866#if defined (ALIAS)-
1867 if (ap)
apDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-82
1868 ap->flags |= AL_BEINGEXPANDED;
executed 82 times by 1 test: ap->flags |= 0x2;
Executed by:
  • Self test
82
1869#endif-
1870-
1871 shell_input_line = s;-
1872 shell_input_line_size = STRLEN (s);
(s)[1]Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(s)[2]Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(s)Description
TRUEevaluated 102 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
(s)[0]Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-102
1873 shell_input_line_index = 0;-
1874 shell_input_line_terminator = '\0';-
1875#if 0-
1876 parser_state &= ~PST_ALEXPNEXT; /* XXX */-
1877#endif-
1878-
1879 set_line_mbstate ();-
1880}
executed 120 times by 1 test: end of block
Executed by:
  • Self test
120
1881-
1882/*-
1883 * Make the top of the pushed_string stack be the current shell input.-
1884 * Only called when there is something on the stack. Called from shell_getc-
1885 * when it thinks it has consumed the string generated by an alias expansion-
1886 * and needs to return to the original input line.-
1887 */-
1888static void-
1889pop_string ()-
1890{-
1891 STRING_SAVER *t;-
1892-
1893 FREE (shell_input_line);
executed 110 times by 1 test: sh_xfree((shell_input_line), "./parse.y", 1893);
Executed by:
  • Self test
shell_input_lineDescription
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-110
1894 shell_input_line = pushed_string_list->saved_line;-
1895 shell_input_line_index = pushed_string_list->saved_line_index;-
1896 shell_input_line_size = pushed_string_list->saved_line_size;-
1897 shell_input_line_terminator = pushed_string_list->saved_line_terminator;-
1898-
1899 if (pushed_string_list->expand_alias)
pushed_string_...->expand_aliasDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 105 times by 1 test
Evaluated by:
  • Self test
5-105
1900 parser_state |= PST_ALEXPNEXT;
executed 5 times by 1 test: parser_state |= 0x000002;
Executed by:
  • Self test
5
1901 else-
1902 parser_state &= ~PST_ALEXPNEXT;
executed 105 times by 1 test: parser_state &= ~0x000002;
Executed by:
  • Self test
105
1903-
1904 t = pushed_string_list;-
1905 pushed_string_list = pushed_string_list->next;-
1906-
1907#if defined (ALIAS)-
1908 if (t->expander)
t->expanderDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-72
1909 t->expander->flags &= ~AL_BEINGEXPANDED;
executed 72 times by 1 test: t->expander->flags &= ~0x2;
Executed by:
  • Self test
72
1910#endif-
1911-
1912 free ((char *)t);-
1913-
1914 set_line_mbstate ();-
1915}
executed 110 times by 1 test: end of block
Executed by:
  • Self test
110
1916-
1917static void-
1918free_string_list ()-
1919{-
1920 register STRING_SAVER *t, *t1;-
1921-
1922 for (t = pushed_string_list; t; )
tDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4334 times by 1 test
Evaluated by:
  • Self test
2-4334
1923 {-
1924 t1 = t->next;-
1925 FREE (t->saved_line);
executed 2 times by 1 test: sh_xfree((t->saved_line), "./parse.y", 1925);
Executed by:
  • Self test
t->saved_lineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
1926#if defined (ALIAS)-
1927 if (t->expander)
t->expanderDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
1928 t->expander->flags &= ~AL_BEINGEXPANDED;
executed 2 times by 1 test: t->expander->flags &= ~0x2;
Executed by:
  • Self test
2
1929#endif-
1930 free ((char *)t);-
1931 t = t1;-
1932 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
1933 pushed_string_list = (STRING_SAVER *)NULL;-
1934}
executed 4334 times by 1 test: end of block
Executed by:
  • Self test
4334
1935-
1936#endif /* ALIAS || DPAREN_ARITHMETIC */-
1937-
1938void-
1939free_pushed_string_input ()-
1940{-
1941#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
1942 free_string_list ();-
1943#endif-
1944}
executed 4332 times by 1 test: end of block
Executed by:
  • Self test
4332
1945-
1946int-
1947parser_expanding_alias ()-
1948{-
1949 return (expanding_alias ());
executed 1453134 times by 1 test: return ((pushed_string_list && pushed_string_list->expander));
Executed by:
  • Self test
1453134
1950}-
1951-
1952void-
1953parser_save_alias ()-
1954{-
1955#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
1956 push_string ((char *)NULL, 0, (alias_t *)NULL);-
1957 pushed_string_list->flags = PSH_SOURCE; /* XXX - for now */-
1958#else-
1959 ;-
1960#endif-
1961}
executed 18 times by 1 test: end of block
Executed by:
  • Self test
18
1962-
1963void-
1964parser_restore_alias ()-
1965{-
1966#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
1967 if (pushed_string_list)
pushed_string_listDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14
1968 pop_string ();
executed 14 times by 1 test: pop_string ();
Executed by:
  • Self test
14
1969#else-
1970 ;-
1971#endif-
1972}
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
1973-
1974#if defined (ALIAS)-
1975/* Before freeing AP, make sure that there aren't any cases of pointer-
1976 aliasing that could cause us to reference freed memory later on. */-
1977void-
1978clear_string_list_expander (ap)-
1979 alias_t *ap;-
1980{-
1981 register STRING_SAVER *t;-
1982-
1983 for (t = pushed_string_list; t; t = t->next)
tDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4
1984 {-
1985 if (t->expander && t->expander == ap)
t->expanderDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
t->expander == apDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
1986 t->expander = 0;
executed 4 times by 1 test: t->expander = 0;
Executed by:
  • Self test
4
1987 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
1988}
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
1989#endif-
1990-
1991void-
1992clear_shell_input_line ()-
1993{-
1994 if (shell_input_line)
shell_input_lineDescription
TRUEevaluated 20976 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 291 times by 1 test
Evaluated by:
  • Self test
291-20976
1995 shell_input_line[shell_input_line_index = 0] = '\0';
executed 20976 times by 1 test: shell_input_line[shell_input_line_index = 0] = '\0';
Executed by:
  • Self test
20976
1996}
executed 21267 times by 1 test: end of block
Executed by:
  • Self test
21267
1997-
1998/* Return a line of text, taken from wherever yylex () reads input.-
1999 If there is no more input, then we return NULL. If REMOVE_QUOTED_NEWLINE-
2000 is non-zero, we remove unquoted \<newline> pairs. This is used by-
2001 read_secondary_line to read here documents. */-
2002static char *-
2003read_a_line (remove_quoted_newline)-
2004 int remove_quoted_newline;-
2005{-
2006 static char *line_buffer = (char *)NULL;-
2007 static int buffer_size = 0;-
2008 int indx, c, peekc, pass_next;-
2009-
2010#if defined (READLINE)-
2011 if (no_line_editing && SHOULD_PROMPT ())
no_line_editingDescription
TRUEevaluated 5258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
interactiveDescription
TRUEnever evaluated
FALSEevaluated 5258 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-5258
2012#else-
2013 if (SHOULD_PROMPT ())-
2014#endif-
2015 print_prompt ();
never executed: print_prompt ();
0
2016-
2017 pass_next = indx = 0;-
2018 while (1)-
2019 {-
2020 /* Allow immediate exit if interrupted during input. */-
2021 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 54784 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 54784 times by 1 test
Evaluated by:
  • Self test
0-54784
2022-
2023 c = yy_getc ();-
2024-
2025 /* Ignore null bytes in input. */-
2026 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 54784 times by 1 test
Evaluated by:
  • Self test
0-54784
2027 {-
2028#if 0-
2029 internal_warning ("read_a_line: ignored null byte in input");-
2030#endif-
2031 continue;
never executed: continue;
0
2032 }-
2033-
2034 /* If there is no more input, then we return NULL. */-
2035 if (c == EOF)
c == (-1)Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54751 times by 1 test
Evaluated by:
  • Self test
33-54751
2036 {-
2037 if (interactive && bash_input.type == st_stream)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-33
2038 clearerr (stdin);
never executed: clearerr ( stdin );
0
2039 if (indx == 0)
indx == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-17
2040 return ((char *)NULL);
executed 17 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
17
2041 c = '\n';-
2042 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
2043-
2044 /* `+2' in case the final character in the buffer is a newline. */-
2045 RESIZE_MALLOCED_BUFFER (line_buffer, indx, 2, buffer_size, 128);
executed 1314 times by 1 test: buffer_size += (128);
Executed by:
  • Self test
executed 1314 times by 1 test: end of block
Executed by:
  • Self test
(indx) + (2) >= buffer_sizeDescription
TRUEevaluated 1314 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53453 times by 1 test
Evaluated by:
  • Self test
(indx) + (2) >= buffer_sizeDescription
TRUEevaluated 1314 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1314 times by 1 test
Evaluated by:
  • Self test
1314-53453
2046-
2047 /* IF REMOVE_QUOTED_NEWLINES is non-zero, we are reading a-
2048 here document with an unquoted delimiter. In this case,-
2049 the line will be expanded as if it were in double quotes.-
2050 We allow a backslash to escape the next character, but we-
2051 need to treat the backslash specially only if a backslash-
2052 quoting a backslash-newline pair appears in the line. */-
2053 if (pass_next)
pass_nextDescription
TRUEevaluated 1161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53606 times by 1 test
Evaluated by:
  • Self test
1161-53606
2054 {-
2055 line_buffer[indx++] = c;-
2056 pass_next = 0;-
2057 }
executed 1161 times by 1 test: end of block
Executed by:
  • Self test
1161
2058 else if (c == '\\' && remove_quoted_newline)
c == '\\'Description
TRUEevaluated 1183 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 52423 times by 1 test
Evaluated by:
  • Self test
remove_quoted_newlineDescription
TRUEevaluated 1165 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
18-52423
2059 {-
2060 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 1165 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 1165 times by 1 test
Evaluated by:
  • Self test
0-1165
2061 peekc = yy_getc ();-
2062 if (peekc == '\n')
peekc == '\n'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1161 times by 1 test
Evaluated by:
  • Self test
4-1161
2063 {-
2064 line_number++;-
2065 continue; /* Make the unquoted \<newline> pair disappear. */
executed 4 times by 1 test: continue;
Executed by:
  • Self test
4
2066 }-
2067 else-
2068 {-
2069 yy_ungetc (peekc);-
2070 pass_next = 1;-
2071 line_buffer[indx++] = c; /* Preserve the backslash. */-
2072 }
executed 1161 times by 1 test: end of block
Executed by:
  • Self test
1161
2073 }-
2074 else-
2075 line_buffer[indx++] = c;
executed 52441 times by 1 test: line_buffer[indx++] = c;
Executed by:
  • Self test
52441
2076-
2077 if (c == '\n')
c == '\n'Description
TRUEevaluated 5241 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49522 times by 1 test
Evaluated by:
  • Self test
5241-49522
2078 {-
2079 line_buffer[indx] = '\0';-
2080 return (line_buffer);
executed 5241 times by 1 test: return (line_buffer);
Executed by:
  • Self test
5241
2081 }-
2082 }
executed 49522 times by 1 test: end of block
Executed by:
  • Self test
49522
2083}
never executed: end of block
0
2084-
2085/* Return a line as in read_a_line (), but insure that the prompt is-
2086 the secondary prompt. This is used to read the lines of a here-
2087 document. REMOVE_QUOTED_NEWLINE is non-zero if we should remove-
2088 newlines quoted with backslashes while reading the line. It is-
2089 non-zero unless the delimiter of the here document was quoted. */-
2090char *-
2091read_secondary_line (remove_quoted_newline)-
2092 int remove_quoted_newline;-
2093{-
2094 char *ret;-
2095 int n, c;-
2096-
2097 prompt_string_pointer = &ps2_prompt;-
2098 if (SHOULD_PROMPT())
interactiveDescription
TRUEnever evaluated
FALSEevaluated 5258 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-5258
2099 prompt_again ();
never executed: prompt_again ();
0
2100 ret = read_a_line (remove_quoted_newline);-
2101#if defined (HISTORY)-
2102 if (ret && remember_on_history && (parser_state & PST_HEREDOC))
retDescription
TRUEevaluated 5241 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
remember_on_historyDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5237 times by 1 test
Evaluated by:
  • Self test
(parser_state & 0x020000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5241
2103 {-
2104 /* To make adding the here-document body right, we need to rely on-
2105 history_delimiting_chars() returning \n for the first line of the-
2106 here-document body and the null string for the second and subsequent-
2107 lines, so we avoid double newlines.-
2108 current_command_line_count == 2 for the first line of the body. */-
2109-
2110 current_command_line_count++;-
2111 maybe_add_history (ret);-
2112 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
2113#endif /* HISTORY */-
2114 return ret;
executed 5258 times by 1 test: return ret;
Executed by:
  • Self test
5258
2115}-
2116-
2117/* **************************************************************** */-
2118/* */-
2119/* YYLEX () */-
2120/* */-
2121/* **************************************************************** */-
2122-
2123/* Reserved words. These are only recognized as the first word of a-
2124 command. */-
2125STRING_INT_ALIST word_token_alist[] = {-
2126 { "if", IF },-
2127 { "then", THEN },-
2128 { "else", ELSE },-
2129 { "elif", ELIF },-
2130 { "fi", FI },-
2131 { "case", CASE },-
2132 { "esac", ESAC },-
2133 { "for", FOR },-
2134#if defined (SELECT_COMMAND)-
2135 { "select", SELECT },-
2136#endif-
2137 { "while", WHILE },-
2138 { "until", UNTIL },-
2139 { "do", DO },-
2140 { "done", DONE },-
2141 { "in", IN },-
2142 { "function", FUNCTION },-
2143#if defined (COMMAND_TIMING)-
2144 { "time", TIME },-
2145#endif-
2146 { "{", '{' },-
2147 { "}", '}' },-
2148 { "!", BANG },-
2149#if defined (COND_COMMAND)-
2150 { "[[", COND_START },-
2151 { "]]", COND_END },-
2152#endif-
2153#if defined (COPROCESS_SUPPORT)-
2154 { "coproc", COPROC },-
2155#endif-
2156 { (char *)NULL, 0}-
2157};-
2158-
2159/* other tokens that can be returned by read_token() */-
2160STRING_INT_ALIST other_token_alist[] = {-
2161 /* Multiple-character tokens with special values */-
2162 { "--", TIMEIGN },-
2163 { "-p", TIMEOPT },-
2164 { "&&", AND_AND },-
2165 { "||", OR_OR },-
2166 { ">>", GREATER_GREATER },-
2167 { "<<", LESS_LESS },-
2168 { "<&", LESS_AND },-
2169 { ">&", GREATER_AND },-
2170 { ";;", SEMI_SEMI },-
2171 { ";&", SEMI_AND },-
2172 { ";;&", SEMI_SEMI_AND },-
2173 { "<<-", LESS_LESS_MINUS },-
2174 { "<<<", LESS_LESS_LESS },-
2175 { "&>", AND_GREATER },-
2176 { "&>>", AND_GREATER_GREATER },-
2177 { "<>", LESS_GREATER },-
2178 { ">|", GREATER_BAR },-
2179 { "|&", BAR_AND },-
2180 { "EOF", yacc_EOF },-
2181 /* Tokens whose value is the character itself */-
2182 { ">", '>' },-
2183 { "<", '<' },-
2184 { "-", '-' },-
2185 { "{", '{' },-
2186 { "}", '}' },-
2187 { ";", ';' },-
2188 { "(", '(' },-
2189 { ")", ')' },-
2190 { "|", '|' },-
2191 { "&", '&' },-
2192 { "newline", '\n' },-
2193 { (char *)NULL, 0}-
2194};-
2195-
2196/* others not listed here:-
2197 WORD look at yylval.word-
2198 ASSIGNMENT_WORD look at yylval.word-
2199 NUMBER look at yylval.number-
2200 ARITH_CMD look at yylval.word_list-
2201 ARITH_FOR_EXPRS look at yylval.word_list-
2202 COND_CMD look at yylval.command-
2203*/-
2204-
2205/* These are used by read_token_word, but appear up here so that shell_getc-
2206 can use them to decide when to add otherwise blank lines to the history. */-
2207-
2208/* The primary delimiter stack. */-
2209struct dstack dstack = { (char *)NULL, 0, 0 };-
2210-
2211/* A temporary delimiter stack to be used when decoding prompt strings.-
2212 This is needed because command substitutions in prompt strings (e.g., PS2)-
2213 can screw up the parser's quoting state. */-
2214static struct dstack temp_dstack = { (char *)NULL, 0, 0 };-
2215-
2216/* Macro for accessing the top delimiter on the stack. Returns the-
2217 delimiter or zero if none. */-
2218#define current_delimiter(ds) \-
2219 (ds.delimiter_depth ? ds.delimiters[ds.delimiter_depth - 1] : 0)-
2220-
2221#define push_delimiter(ds, character) \-
2222 do \-
2223 { \-
2224 if (ds.delimiter_depth + 2 > ds.delimiter_space) \-
2225 ds.delimiters = (char *)xrealloc \-
2226 (ds.delimiters, (ds.delimiter_space += 10) * sizeof (char)); \-
2227 ds.delimiters[ds.delimiter_depth] = character; \-
2228 ds.delimiter_depth++; \-
2229 } \-
2230 while (0)-
2231-
2232#define pop_delimiter(ds) ds.delimiter_depth---
2233-
2234/* Return the next shell input character. This always reads characters-
2235 from shell_input_line; when that line is exhausted, it is time to-
2236 read the next line. This is called by read_token when the shell is-
2237 processing normal command input. */-
2238-
2239/* This implements one-character lookahead/lookbehind across physical input-
2240 lines, to avoid something being lost because it's pushed back with-
2241 shell_ungetc when we're at the start of a line. */-
2242static int eol_ungetc_lookahead = 0;-
2243-
2244static int-
2245shell_getc (remove_quoted_newline)-
2246 int remove_quoted_newline;-
2247{-
2248 register int i;-
2249 int c, truncating, last_was_backslash;-
2250 unsigned char uc;-
2251-
2252 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 24151082 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 24151082 times by 1 test
Evaluated by:
  • Self test
0-24151082
2253-
2254 last_was_backslash = 0;-
2255 if (sigwinch_received)
sigwinch_receivedDescription
TRUEnever evaluated
FALSEevaluated 24151082 times by 1 test
Evaluated by:
  • Self test
0-24151082
2256 {-
2257 sigwinch_received = 0;-
2258 get_new_window_size (0, (int *)0, (int *)0);-
2259 }
never executed: end of block
0
2260 -
2261 if (eol_ungetc_lookahead)
eol_ungetc_lookaheadDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24151080 times by 1 test
Evaluated by:
  • Self test
2-24151080
2262 {-
2263 c = eol_ungetc_lookahead;-
2264 eol_ungetc_lookahead = 0;-
2265 return (c);
executed 2 times by 1 test: return (c);
Executed by:
  • Self test
2
2266 }-
2267-
2268#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
2269 /* If shell_input_line[shell_input_line_index] == 0, but there is-
2270 something on the pushed list of strings, then we don't want to go-
2271 off and get another line. We let the code down below handle it. */-
2272-
2273 if (!shell_input_line || ((!shell_input_line[shell_input_line_index]) &&
!shell_input_lineDescription
TRUEevaluated 710883 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23440197 times by 1 test
Evaluated by:
  • Self test
(!shell_input_...t_line_index])Description
TRUEevaluated 717182 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22723015 times by 1 test
Evaluated by:
  • Self test
710883-23440197
2274 (pushed_string_list == (STRING_SAVER *)NULL)))
(pushed_string... ((void *)0) )Description
TRUEevaluated 716995 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 187 times by 1 test
Evaluated by:
  • Self test
187-716995
2275#else /* !ALIAS && !DPAREN_ARITHMETIC */-
2276 if (!shell_input_line || !shell_input_line[shell_input_line_index])-
2277#endif /* !ALIAS && !DPAREN_ARITHMETIC */-
2278 {-
2279 line_number++;-
2280-
2281 /* Let's not let one really really long line blow up memory allocation */-
2282 if (shell_input_line && shell_input_line_size >= 32768)
shell_input_lineDescription
TRUEevaluated 716995 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 710883 times by 1 test
Evaluated by:
  • Self test
shell_input_line_size >= 32768Description
TRUEnever evaluated
FALSEevaluated 716995 times by 1 test
Evaluated by:
  • Self test
0-716995
2283 {-
2284 free (shell_input_line);-
2285 shell_input_line = 0;-
2286 shell_input_line_size = 0;-
2287 }
never executed: end of block
0
2288-
2289 restart_read:
code before this statement executed 1427878 times by 1 test: restart_read:
Executed by:
  • Self test
1427878
2290-
2291 /* Allow immediate exit if interrupted during input. */-
2292 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 1464900 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 1464900 times by 1 test
Evaluated by:
  • Self test
0-1464900
2293-
2294 i = truncating = 0;-
2295 shell_input_line_terminator = 0;-
2296-
2297 /* If the shell is interatctive, but not currently printing a prompt-
2298 (interactive_shell && interactive == 0), we don't want to print-
2299 notifies or cleanup the jobs -- we want to defer it until we do-
2300 print the next prompt. */-
2301 if (interactive_shell == 0 || SHOULD_PROMPT())
interactive_shell == 0Description
TRUEevaluated 1459523 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5377 times by 1 test
Evaluated by:
  • Self test
interactiveDescription
TRUEnever evaluated
FALSEevaluated 5377 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-1459523
2302 {-
2303#if defined (JOB_CONTROL)-
2304 /* This can cause a problem when reading a command as the result-
2305 of a trap, when the trap is called from flush_child. This call-
2306 had better not cause jobs to disappear from the job table in-
2307 that case, or we will have big trouble. */-
2308 notify_and_cleanup ();-
2309#else /* !JOB_CONTROL */-
2310 cleanup_dead_jobs ();-
2311#endif /* !JOB_CONTROL */-
2312 }
executed 1459523 times by 1 test: end of block
Executed by:
  • Self test
1459523
2313-
2314#if defined (READLINE)-
2315 if (no_line_editing && SHOULD_PROMPT())
no_line_editingDescription
TRUEevaluated 1459497 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5403 times by 1 test
Evaluated by:
  • Self test
interactiveDescription
TRUEnever evaluated
FALSEevaluated 1459497 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-1459497
2316#else-
2317 if (SHOULD_PROMPT())-
2318#endif-
2319 print_prompt ();
never executed: print_prompt ();
0
2320-
2321 if (bash_input.type == st_stream)
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEevaluated 1464900 times by 1 test
Evaluated by:
  • Self test
0-1464900
2322 clearerr (stdin);
never executed: clearerr ( stdin );
0
2323-
2324 while (1)-
2325 {-
2326 c = yy_getc ();-
2327-
2328 /* Allow immediate exit if interrupted during input. */-
2329 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 20751284 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 20751284 times by 1 test
Evaluated by:
  • Self test
0-20751284
2330-
2331 if (c == '\0')
c == '\0'Description
TRUEnever evaluated
FALSEevaluated 20751284 times by 1 test
Evaluated by:
  • Self test
0-20751284
2332 {-
2333#if 0-
2334 internal_warning ("shell_getc: ignored null byte in input");-
2335#endif-
2336 /* If we get EOS while parsing a string, treat it as EOF so we-
2337 don't just keep looping. Happens very rarely */-
2338 if (bash_input.type == st_string)
bash_input.type == st_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
2339 {-
2340 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2341 shell_input_line_terminator = EOF;
never executed: shell_input_line_terminator = (-1) ;
0
2342 shell_input_line[i] = '\0';-
2343 c = EOF;-
2344 break;
never executed: break;
0
2345 }-
2346 continue;
never executed: continue;
0
2347 }-
2348-
2349 /* Theoretical overflow */-
2350 /* If we can't put 256 bytes more into the buffer, allocate-
2351 everything we can and fill it as full as we can. */-
2352 /* XXX - we ignore rest of line using `truncating' flag */-
2353 if (shell_input_line_size > (SIZE_MAX - 256))
shell_input_li...1615UL) - 256)Description
TRUEnever evaluated
FALSEevaluated 20751284 times by 1 test
Evaluated by:
  • Self test
0-20751284
2354 {-
2355 size_t n;-
2356-
2357 n = SIZE_MAX - i; /* how much more can we put into the buffer? */-
2358 if (n <= 2) /* we have to save 1 for the newline added below */
n <= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
2359 {-
2360 if (truncating == 0)
truncating == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2361 internal_warning(_("shell_getc: shell_input_line_size (%zu) exceeds SIZE_MAX (%lu): line truncated"), shell_input_line_size, (unsigned long)SIZE_MAX);
never executed: internal_warning( dcgettext (((void *)0), "shell_getc: shell_input_line_size (%zu) exceeds SIZE_MAX (%lu): line truncated" , 5) , shell_input_line_size, (unsigned long) (18446744073709551615UL) );
0
2362 shell_input_line[i] = '\0';-
2363 truncating = 1;-
2364 }
never executed: end of block
0
2365 if (shell_input_line_size < SIZE_MAX)
shell_input_li...73709551615UL)Description
TRUEnever evaluated
FALSEnever evaluated
0
2366 {-
2367 shell_input_line_size = SIZE_MAX;-
2368 shell_input_line = xrealloc (shell_input_line, shell_input_line_size);-
2369 }
never executed: end of block
0
2370 }
never executed: end of block
0
2371 else-
2372 RESIZE_MALLOCED_BUFFER (shell_input_line, i, 2, shell_input_line_size, 256);
executed 711448 times by 1 test: shell_input_line_size += (256);
Executed by:
  • Self test
executed 711448 times by 1 test: end of block
Executed by:
  • Self test
executed 20751284 times by 1 test: end of block
Executed by:
  • Self test
(i) + (2) >= s...nput_line_sizeDescription
TRUEevaluated 711448 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20039836 times by 1 test
Evaluated by:
  • Self test
(i) + (2) >= s...nput_line_sizeDescription
TRUEevaluated 711448 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 711448 times by 1 test
Evaluated by:
  • Self test
711448-20751284
2373-
2374 if (c == EOF)
c == (-1)Description
TRUEevaluated 725879 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20025405 times by 1 test
Evaluated by:
  • Self test
725879-20025405
2375 {-
2376 if (bash_input.type == st_stream)
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEevaluated 725879 times by 1 test
Evaluated by:
  • Self test
0-725879
2377 clearerr (stdin);
never executed: clearerr ( stdin );
0
2378-
2379 if (i == 0)
i == 0Description
TRUEevaluated 369 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 725510 times by 1 test
Evaluated by:
  • Self test
369-725510
2380 shell_input_line_terminator = EOF;
executed 369 times by 1 test: shell_input_line_terminator = (-1) ;
Executed by:
  • Self test
369
2381-
2382 shell_input_line[i] = '\0';-
2383 break;
executed 725879 times by 1 test: break;
Executed by:
  • Self test
725879
2384 }-
2385-
2386 if (truncating == 0 || c == '\n')
truncating == 0Description
TRUEevaluated 20025405 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0-20025405
2387 shell_input_line[i++] = c;
executed 20025405 times by 1 test: shell_input_line[i++] = c;
Executed by:
  • Self test
20025405
2388-
2389 if (c == '\n')
c == '\n'Description
TRUEevaluated 739021 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19286384 times by 1 test
Evaluated by:
  • Self test
739021-19286384
2390 {-
2391 shell_input_line[--i] = '\0';-
2392 current_command_line_count++;-
2393 break;
executed 739021 times by 1 test: break;
Executed by:
  • Self test
739021
2394 }-
2395-
2396 last_was_backslash = last_was_backslash == 0 && c == '\\';
last_was_backslash == 0Description
TRUEevaluated 19122968 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 163416 times by 1 test
Evaluated by:
  • Self test
c == '\\'Description
TRUEevaluated 200702 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18922266 times by 1 test
Evaluated by:
  • Self test
163416-19122968
2397 }
executed 19286384 times by 1 test: end of block
Executed by:
  • Self test
19286384
2398-
2399 shell_input_line_index = 0;-
2400 shell_input_line_len = i; /* == strlen (shell_input_line) */-
2401-
2402 set_line_mbstate ();-
2403-
2404#if defined (HISTORY)-
2405 if (remember_on_history && shell_input_line && shell_input_line[0])
remember_on_historyDescription
TRUEevaluated 685 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1464215 times by 1 test
Evaluated by:
  • Self test
shell_input_lineDescription
TRUEevaluated 685 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
shell_input_line[0]Description
TRUEevaluated 491 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 194 times by 1 test
Evaluated by:
  • Self test
0-1464215
2406 {-
2407 char *expansions;-
2408# if defined (BANG_HISTORY)-
2409 int old_hist;-
2410-
2411 /* If the current delimiter is a single quote, we should not be-
2412 performing history expansion, even if we're on a different-
2413 line from the original single quote. */-
2414 old_hist = history_expansion_inhibited;-
2415 if (current_delimiter (dstack) == '\'')
(dstack.delimi...] : 0) == '\''Description
TRUEnever evaluated
FALSEevaluated 491 times by 1 test
Evaluated by:
  • Self test
dstack.delimiter_depthDescription
TRUEnever evaluated
FALSEevaluated 491 times by 1 test
Evaluated by:
  • Self test
0-491
2416 history_expansion_inhibited = 1;
never executed: history_expansion_inhibited = 1;
0
2417# endif-
2418 /* Calling with a third argument of 1 allows remember_on_history to-
2419 determine whether or not the line is saved to the history list */-
2420 expansions = pre_process_line (shell_input_line, 1, 1);-
2421# if defined (BANG_HISTORY)-
2422 history_expansion_inhibited = old_hist;-
2423# endif-
2424 if (expansions != shell_input_line)
expansions != shell_input_lineDescription
TRUEevaluated 206 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 285 times by 1 test
Evaluated by:
  • Self test
206-285
2425 {-
2426 free (shell_input_line);-
2427 shell_input_line = expansions;-
2428 shell_input_line_len = shell_input_line ?
shell_input_lineDescription
TRUEevaluated 202 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-202
2429 strlen (shell_input_line) : 0;-
2430 if (shell_input_line_len == 0)
shell_input_line_len == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 202 times by 1 test
Evaluated by:
  • Self test
4-202
2431 current_command_line_count--;
executed 4 times by 1 test: current_command_line_count--;
Executed by:
  • Self test
4
2432-
2433 /* We have to force the xrealloc below because we don't know-
2434 the true allocated size of shell_input_line anymore. */-
2435 shell_input_line_size = shell_input_line_len;-
2436-
2437 set_line_mbstate ();-
2438 }
executed 206 times by 1 test: end of block
Executed by:
  • Self test
206
2439 }
executed 491 times by 1 test: end of block
Executed by:
  • Self test
491
2440 /* Try to do something intelligent with blank lines encountered while-
2441 entering multi-line commands. XXX - this is grotesque */-
2442 else if (remember_on_history && shell_input_line &&
remember_on_historyDescription
TRUEevaluated 194 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1464215 times by 1 test
Evaluated by:
  • Self test
shell_input_lineDescription
TRUEevaluated 194 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1464215
2443 shell_input_line[0] == '\0' &&
shell_input_line[0] == '\0'Description
TRUEevaluated 194 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-194
2444 current_command_line_count > 1)
current_command_line_count > 1Description
TRUEnever evaluated
FALSEevaluated 194 times by 1 test
Evaluated by:
  • Self test
0-194
2445 {-
2446 if (current_delimiter (dstack))
(dstack.delimi...epth - 1] : 0)Description
TRUEnever evaluated
FALSEnever evaluated
dstack.delimiter_depthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2447 /* We know shell_input_line[0] == 0 and we're reading some sort of-
2448 quoted string. This means we've got a line consisting of only-
2449 a newline in a quoted string. We want to make sure this line-
2450 gets added to the history. */-
2451 maybe_add_history (shell_input_line);
never executed: maybe_add_history (shell_input_line);
0
2452 else-
2453 {-
2454 char *hdcs;-
2455 hdcs = history_delimiting_chars (shell_input_line);-
2456 if (hdcs && hdcs[0] == ';')
hdcsDescription
TRUEnever evaluated
FALSEnever evaluated
hdcs[0] == ';'Description
TRUEnever evaluated
FALSEnever evaluated
0
2457 maybe_add_history (shell_input_line);
never executed: maybe_add_history (shell_input_line);
0
2458 }
never executed: end of block
0
2459 }-
2460-
2461#endif /* HISTORY */-
2462-
2463 if (shell_input_line)
shell_input_lineDescription
TRUEevaluated 1464896 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-1464896
2464 {-
2465 /* Lines that signify the end of the shell's input should not be-
2466 echoed. We should not echo lines while parsing command-
2467 substitutions with recursive calls into the parsing engine; those-
2468 should only be echoed once when we read the word. That is the-
2469 reason for the test against shell_eof_token, which is set to a-
2470 right paren when parsing the contents of command substitutions. */-
2471 if (echo_input_at_read && (shell_input_line[0] ||
echo_input_at_readDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1464894 times by 1 test
Evaluated by:
  • Self test
shell_input_line[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1464894
2472 shell_input_line_terminator != EOF) &&
shell_input_li...inator != (-1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2473 shell_eof_token == 0)
shell_eof_token == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
2474 fprintf (stderr, "%s\n", shell_input_line);
executed 2 times by 1 test: fprintf ( stderr , "%s\n", shell_input_line);
Executed by:
  • Self test
2
2475 }
executed 1464896 times by 1 test: end of block
Executed by:
  • Self test
1464896
2476 else-
2477 {-
2478 shell_input_line_size = 0;-
2479 prompt_string_pointer = &current_prompt_string;-
2480 if (SHOULD_PROMPT ())
interactiveDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-4
2481 prompt_again ();
never executed: prompt_again ();
0
2482 goto restart_read;
executed 4 times by 1 test: goto restart_read;
Executed by:
  • Self test
4
2483 }-
2484-
2485 /* Add the newline to the end of this string, iff the string does-
2486 not already end in an EOF character. */-
2487 if (shell_input_line_terminator != EOF)
shell_input_li...inator != (-1)Description
TRUEevaluated 1464527 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 369 times by 1 test
Evaluated by:
  • Self test
369-1464527
2488 {-
2489 if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
shell_input_li...09551615UL) -3Description
TRUEevaluated 1464527 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(shell_input_l...put_line_size)Description
TRUEevaluated 202 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1464325 times by 1 test
Evaluated by:
  • Self test
0-1464527
2490 shell_input_line = (char *)xrealloc (shell_input_line,
executed 202 times by 1 test: shell_input_line = (char *)sh_xrealloc((shell_input_line), (1 + (shell_input_line_size += 2)), "./parse.y" , 2491 ) ;
Executed by:
  • Self test
202
2491 1 + (shell_input_line_size += 2));
executed 202 times by 1 test: shell_input_line = (char *)sh_xrealloc((shell_input_line), (1 + (shell_input_line_size += 2)), "./parse.y" , 2491 ) ;
Executed by:
  • Self test
202
2492-
2493 /* Don't add a newline to a string that ends with a backslash if we're-
2494 going to be removing quoted newlines, since that will eat the-
2495 backslash. Add another backslash instead (will be removed by-
2496 word expansion). */-
2497 if (bash_input.type == st_string && expanding_alias() == 0 && last_was_backslash && c == EOF && remove_quoted_newline)
bash_input.type == st_stringDescription
TRUEevaluated 737483 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 727044 times by 1 test
Evaluated by:
  • Self test
(pushed_string...expander) == 0Description
TRUEevaluated 737483 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
pushed_string_listDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 737438 times by 1 test
Evaluated by:
  • Self test
pushed_string_list->expanderDescription
TRUEnever evaluated
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
last_was_backslashDescription
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 737166 times by 1 test
Evaluated by:
  • Self test
c == (-1)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 314 times by 1 test
Evaluated by:
  • Self test
remove_quoted_newlineDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-737483
2498 shell_input_line[shell_input_line_len] = '\\';
executed 3 times by 1 test: shell_input_line[shell_input_line_len] = '\\';
Executed by:
  • Self test
3
2499 else-
2500 shell_input_line[shell_input_line_len] = '\n';
executed 1464524 times by 1 test: shell_input_line[shell_input_line_len] = '\n';
Executed by:
  • Self test
1464524
2501 shell_input_line[shell_input_line_len + 1] = '\0';-
2502-
2503 set_line_mbstate ();-
2504 }
executed 1464527 times by 1 test: end of block
Executed by:
  • Self test
1464527
2505 }
executed 1464896 times by 1 test: end of block
Executed by:
  • Self test
1464896
2506-
2507next_alias_char:
code before this statement executed 24188098 times by 1 test: next_alias_char:
Executed by:
  • Self test
24188098
2508 uc = shell_input_line[shell_input_line_index];-
2509-
2510 if (uc)
ucDescription
TRUEevaluated 24187542 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 556 times by 1 test
Evaluated by:
  • Self test
556-24187542
2511 shell_input_line_index++;
executed 24187542 times by 1 test: shell_input_line_index++;
Executed by:
  • Self test
24187542
2512-
2513#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
2514 /* If UC is NULL, we have reached the end of the current input string. If-
2515 pushed_string_list is non-empty, it's time to pop to the previous string-
2516 because we have fully consumed the result of the last alias expansion.-
2517 Do it transparently; just return the next character of the string popped-
2518 to. */-
2519 /* If pushed_string_list != 0 but pushed_string_list->expander == 0 (not-
2520 currently tested) and the flags value is not PSH_SOURCE, we are not-
2521 parsing an alias, we have just saved one (push_string, when called by-
2522 the parse_dparen code) In this case, just go on as well. The PSH_SOURCE-
2523 case is handled below. */-
2524-
2525 /* If we're at the end of an alias expansion add a space to make sure that-
2526 the alias remains marked as being in use while we expand its last word.-
2527 This makes sure that pop_string doesn't mark the alias as not in use-
2528 before the string resulting from the alias expansion is tokenized and-
2529 checked for alias expansion, preventing recursion. At this point, the-
2530 last character in shell_input_line is the last character of the alias-
2531 expansion. We test that last character to determine whether or not to-
2532 return the space that will delimit the token and postpone the pop_string.-
2533 This set of conditions duplicates what used to be in mk_alexpansion ()-
2534 below, with the addition that we don't add a space if we're currently-
2535 reading a quoted string. */-
2536#ifndef OLD_ALIAS_HACK-
2537 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
uc == 0Description
TRUEevaluated 556 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24187542 times by 1 test
Evaluated by:
  • Self test
pushed_string_listDescription
TRUEevaluated 187 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 369 times by 1 test
Evaluated by:
  • Self test
pushed_string_...>flags != 0x04Description
TRUEevaluated 160 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-24187542
2538 shell_input_line_index > 0 &&
shell_input_line_index > 0Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-158
2539 shell_input_line[shell_input_line_index-1] != ' ' &&
shell_input_li...ndex-1] != ' 'Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
69-89
2540 shell_input_line[shell_input_line_index-1] != '\n' &&
shell_input_li...dex-1] != '\n'Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-86
2541 shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
(sh_syntaxtab[...& 0x0001) == 0Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
20-66
2542 (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
dstack.delimiter_depthDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
dstack.delimiter_depthDescription
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
(dstack.delimi...] : 0) != '\''Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(dstack.delimi...1] : 0) != '"'Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-64
2543 {-
2544 return ' '; /* END_ALIAS */
executed 64 times by 1 test: return ' ';
Executed by:
  • Self test
64
2545 }-
2546#endif-
2547-
2548pop_alias:
code before this statement executed 24188034 times by 1 test: pop_alias:
Executed by:
  • Self test
24188034
2549 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
uc == 0Description
TRUEevaluated 492 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24187542 times by 1 test
Evaluated by:
  • Self test
pushed_string_listDescription
TRUEevaluated 123 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 369 times by 1 test
Evaluated by:
  • Self test
pushed_string_...>flags != 0x04Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-24187542
2550 {-
2551 pop_string ();-
2552 uc = shell_input_line[shell_input_line_index];-
2553 if (uc)
ucDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-96
2554 shell_input_line_index++;
executed 96 times by 1 test: shell_input_line_index++;
Executed by:
  • Self test
96
2555 }
executed 96 times by 1 test: end of block
Executed by:
  • Self test
96
2556#endif /* ALIAS || DPAREN_ARITHMETIC */-
2557-
2558 if MBTEST(uc == '\\' && remove_quoted_newline && shell_input_line[shell_input_line_index] == '\n')
(shell_input_line_index > 1)Description
TRUEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
uc == '\\'Description
TRUEevaluated 201841 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23986193 times by 1 test
Evaluated by:
  • Self test
remove_quoted_newlineDescription
TRUEevaluated 192368 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9473 times by 1 test
Evaluated by:
  • Self test
shell_input_li...index] == '\n'Description
TRUEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 155377 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-23986193
2559 {-
2560 if (SHOULD_PROMPT ())
interactiveDescription
TRUEnever evaluated
FALSEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-36991
2561 prompt_again ();
never executed: prompt_again ();
0
2562 line_number++;-
2563 /* What do we do here if we're expanding an alias whose definition-
2564 includes an escaped newline? If that's the last character in the-
2565 alias expansion, we just pop the pushed string list (recall that-
2566 we inhibit the appending of a space if newline is the last-
2567 character). If it's not the last character, we need to consume the-
2568 quoted newline and move to the next character in the expansion. */-
2569#if defined (ALIAS)-
2570 if (expanding_alias () && shell_input_line[shell_input_line_index+1] == '\0')
pushed_string_listDescription
TRUEnever evaluated
FALSEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
pushed_string_list->expanderDescription
TRUEnever evaluated
FALSEnever evaluated
shell_input_li...dex+1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-36991
2571 {-
2572 uc = 0;-
2573 goto pop_alias;
never executed: goto pop_alias;
0
2574 }-
2575 else if (expanding_alias () && shell_input_line[shell_input_line_index+1] != '\0')
pushed_string_listDescription
TRUEnever evaluated
FALSEevaluated 36991 times by 1 test
Evaluated by:
  • Self test
pushed_string_list->expanderDescription
TRUEnever evaluated
FALSEnever evaluated
shell_input_li...dex+1] != '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-36991
2576 {-
2577 shell_input_line_index++; /* skip newline */-
2578 goto next_alias_char; /* and get next character */
never executed: goto next_alias_char;
0
2579 }-
2580 else-
2581#endif -
2582 goto restart_read;
executed 36991 times by 1 test: goto restart_read;
Executed by:
  • Self test
36991
2583 }-
2584-
2585 if (uc == 0 && shell_input_line_terminator == EOF)
uc == 0Description
TRUEevaluated 396 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24150647 times by 1 test
Evaluated by:
  • Self test
shell_input_li...inator == (-1)Description
TRUEevaluated 369 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-24150647
2586 return ((shell_input_line_index != 0) ? '\n' : EOF);
executed 369 times by 1 test: return ((shell_input_line_index != 0) ? '\n' : (-1) );
Executed by:
  • Self test
369
2587-
2588#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
2589 /* We already know that we are not parsing an alias expansion because of the-
2590 check for expanding_alias() above. This knows how parse_and_execute-
2591 handles switching to st_string input while an alias is being expanded,-
2592 hence the check for pushed_string_list without pushed_string_list->expander-
2593 and the check for PSH_SOURCE as pushed_string_list->flags.-
2594 parse_and_execute and parse_string both change the input type to st_string-
2595 and place the string to be parsed and executed into location.string, so-
2596 we should not stop reading that until the pointer is '\0'.-
2597 The check for shell_input_line_terminator may be superfluous.-
2598-
2599 This solves the problem of `.' inside a multi-line alias with embedded-
2600 newlines executing things out of order. */-
2601 if (uc == 0 && bash_input.type == st_string && *bash_input.location.string &&
uc == 0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24150647 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stringDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*bash_input.location.stringDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-24150647
2602 pushed_string_list && pushed_string_list->flags == PSH_SOURCE &&
pushed_string_listDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
pushed_string_...>flags == 0x04Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-27
2603 shell_input_line_terminator == 0)
shell_input_li...erminator == 0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-27
2604 {-
2605 shell_input_line_index = 0;-
2606 goto restart_read;
executed 27 times by 1 test: goto restart_read;
Executed by:
  • Self test
27
2607 }-
2608#endif-
2609-
2610 return (uc);
executed 24150647 times by 1 test: return (uc);
Executed by:
  • Self test
24150647
2611}-
2612-
2613/* Put C back into the input for the shell. This might need changes for-
2614 HANDLE_MULTIBYTE around EOLs. Since we (currently) never push back a-
2615 character different than we read, shell_input_line_property doesn't need-
2616 to change when manipulating shell_input_line. The define for-
2617 last_shell_getc_is_singlebyte should take care of it, though. */-
2618static void-
2619shell_ungetc (c)-
2620 int c;-
2621{-
2622 if (shell_input_line && shell_input_line_index)
shell_input_lineDescription
TRUEevaluated 4418581 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
shell_input_line_indexDescription
TRUEevaluated 4418579 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-4418581
2623 shell_input_line[--shell_input_line_index] = c;
executed 4418579 times by 1 test: shell_input_line[--shell_input_line_index] = c;
Executed by:
  • Self test
4418579
2624 else-
2625 eol_ungetc_lookahead = c;
executed 2 times by 1 test: eol_ungetc_lookahead = c;
Executed by:
  • Self test
2
2626}-
2627-
2628char *-
2629parser_remaining_input ()-
2630{-
2631 if (shell_input_line == 0)
shell_input_line == 0Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
0-52
2632 return 0;
never executed: return 0;
0
2633 if ((int)shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len)
(int)shell_inp...line_index < 0Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
shell_input_li...input_line_lenDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-52
2634 return ""; /* XXX */
executed 52 times by 1 test: return "";
Executed by:
  • Self test
52
2635 return (shell_input_line + shell_input_line_index);
never executed: return (shell_input_line + shell_input_line_index);
0
2636}-
2637-
2638#ifdef INCLUDE_UNUSED-
2639/* Back the input pointer up by one, effectively `ungetting' a character. */-
2640static void-
2641shell_ungetchar ()-
2642{-
2643 if (shell_input_line && shell_input_line_index)-
2644 shell_input_line_index--;-
2645}-
2646#endif-
2647-
2648/* Discard input until CHARACTER is seen, then push that character back-
2649 onto the input stream. */-
2650static void-
2651discard_until (character)-
2652 int character;-
2653{-
2654 int c;-
2655-
2656 while ((c = shell_getc (0)) != EOF && c != character)
(c = shell_getc (0)) != (-1)Description
TRUEevaluated 1680916 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c != characterDescription
TRUEevaluated 1645440 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35476 times by 1 test
Evaluated by:
  • Self test
0-1680916
2657 ;
executed 1645440 times by 1 test: ;
Executed by:
  • Self test
1645440
2658-
2659 if (c != EOF)
c != (-1)Description
TRUEevaluated 35476 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-35476
2660 shell_ungetc (c);
executed 35476 times by 1 test: shell_ungetc (c);
Executed by:
  • Self test
35476
2661}
executed 35476 times by 1 test: end of block
Executed by:
  • Self test
35476
2662-
2663void-
2664execute_variable_command (command, vname)-
2665 char *command, *vname;-
2666{-
2667 char *last_lastarg;-
2668 sh_parser_state_t ps;-
2669-
2670 save_parser_state (&ps);-
2671 last_lastarg = get_string_value ("_");-
2672 if (last_lastarg)
last_lastargDescription
TRUEnever evaluated
FALSEnever evaluated
0
2673 last_lastarg = savestring (last_lastarg);
never executed: last_lastarg = (char *)strcpy (sh_xmalloc((1 + strlen (last_lastarg)), "./parse.y", 2673), (last_lastarg));
0
2674-
2675 parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST);-
2676-
2677 restore_parser_state (&ps);-
2678 bind_variable ("_", last_lastarg, 0);-
2679 FREE (last_lastarg);
never executed: sh_xfree((last_lastarg), "./parse.y", 2679);
last_lastargDescription
TRUEnever evaluated
FALSEnever evaluated
0
2680-
2681 if (token_to_read == '\n') /* reset_parser was called */
token_to_read == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
2682 token_to_read = 0;
never executed: token_to_read = 0;
0
2683}
never executed: end of block
0
2684-
2685void-
2686push_token (x)-
2687 int x;-
2688{-
2689 two_tokens_ago = token_before_that;-
2690 token_before_that = last_read_token;-
2691 last_read_token = current_token;-
2692-
2693 current_token = x;-
2694}
never executed: end of block
0
2695-
2696/* Place to remember the token. We try to keep the buffer-
2697 at a reasonable size, but it can grow. */-
2698static char *token = (char *)NULL;-
2699-
2700/* Current size of the token buffer. */-
2701static int token_buffer_size;-
2702-
2703/* Command to read_token () explaining what we want it to do. */-
2704#define READ 0-
2705#define RESET 1-
2706#define prompt_is_ps1 \-
2707 (!prompt_string_pointer || prompt_string_pointer == &ps1_prompt)-
2708-
2709/* Function for yyparse to call. yylex keeps track of-
2710 the last two tokens read, and calls read_token. */-
2711static int-
2712yylex ()-
2713{-
2714 if (interactive && (current_token == 0 || current_token == '\n'))
interactiveDescription
TRUEnever evaluated
FALSEevaluated 4829449 times by 1 test
Evaluated by:
  • Self test
current_token == 0Description
TRUEnever evaluated
FALSEnever evaluated
current_token == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0-4829449
2715 {-
2716 /* Before we print a prompt, we might have to check mailboxes.-
2717 We do this only if it is time to do so. Notice that only here-
2718 is the mail alarm reset; nothing takes place in check_mail ()-
2719 except the checking of mail. Please don't change this. */-
2720 if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ())
!prompt_string_pointerDescription
TRUEnever evaluated
FALSEnever evaluated
prompt_string_...== &ps1_promptDescription
TRUEnever evaluated
FALSEnever evaluated
parse_and_execute_level == 0Description
TRUEnever evaluated
FALSEnever evaluated
time_to_check_mail ()Description
TRUEnever evaluated
FALSEnever evaluated
0
2721 {-
2722 check_mail ();-
2723 reset_mail_timer ();-
2724 }
never executed: end of block
0
2725-
2726 /* Avoid printing a prompt if we're not going to read anything, e.g.-
2727 after resetting the parser with read_token (RESET). */-
2728 if (token_to_read == 0 && SHOULD_PROMPT ())
token_to_read == 0Description
TRUEnever evaluated
FALSEnever evaluated
interactiveDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0
2729 prompt_again ();
never executed: prompt_again ();
0
2730 }
never executed: end of block
0
2731-
2732 two_tokens_ago = token_before_that;-
2733 token_before_that = last_read_token;-
2734 last_read_token = current_token;-
2735 current_token = read_token (READ);-
2736-
2737 if ((parser_state & PST_EOFTOKEN) && current_token == shell_eof_token)
(parser_state & 0x008000)Description
TRUEevaluated 706586 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4122846 times by 1 test
Evaluated by:
  • Self test
current_token ...hell_eof_tokenDescription
TRUEevaluated 961 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705625 times by 1 test
Evaluated by:
  • Self test
961-4122846
2738 {-
2739 current_token = yacc_EOF;-
2740 if (bash_input.type == st_string)
bash_input.type == st_stringDescription
TRUEevaluated 961 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-961
2741 rewind_input_string ();
executed 961 times by 1 test: rewind_input_string ();
Executed by:
  • Self test
961
2742 }
executed 961 times by 1 test: end of block
Executed by:
  • Self test
961
2743 parser_state &= ~PST_EOFTOKEN; /* ??? */-
2744-
2745 return (current_token);
executed 4829432 times by 1 test: return (current_token);
Executed by:
  • Self test
4829432
2746}-
2747-
2748/* When non-zero, we have read the required tokens-
2749 which allow ESAC to be the next one read. */-
2750static int esacs_needed_count;-
2751-
2752/* When non-zero, we can read IN as an acceptable token, regardless of how-
2753 many newlines we read. */-
2754static int expecting_in_token;-
2755-
2756static void-
2757push_heredoc (r)-
2758 REDIRECT *r;-
2759{-
2760 if (need_here_doc >= HEREDOC_MAX)
need_here_doc >= 16Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1750 times by 1 test
Evaluated by:
  • Self test
1-1750
2761 {-
2762 last_command_exit_value = EX_BADUSAGE;-
2763 need_here_doc = 0;-
2764 report_syntax_error (_("maximum here-document count exceeded"));-
2765 reset_parser ();-
2766 exit_shell (last_command_exit_value);-
2767 }
never executed: end of block
0
2768 redir_stack[need_here_doc++] = r;-
2769}
executed 1750 times by 1 test: end of block
Executed by:
  • Self test
1750
2770-
2771void-
2772gather_here_documents ()-
2773{-
2774 int r;-
2775-
2776 r = 0;-
2777 here_doc_first_line = 1;-
2778 while (need_here_doc > 0)
need_here_doc > 0Description
TRUEevaluated 1734 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1730 times by 1 test
Evaluated by:
  • Self test
1730-1734
2779 {-
2780 parser_state |= PST_HEREDOC;-
2781 make_here_document (redir_stack[r++], line_number);-
2782 parser_state &= ~PST_HEREDOC;-
2783 need_here_doc--;-
2784 redir_stack[r - 1] = 0; /* XXX */-
2785 }
executed 1734 times by 1 test: end of block
Executed by:
  • Self test
1734
2786 here_doc_first_line = 0; /* just in case */-
2787}
executed 1730 times by 1 test: end of block
Executed by:
  • Self test
1730
2788-
2789/* When non-zero, an open-brace used to create a group is awaiting a close-
2790 brace partner. */-
2791static int open_brace_count;-
2792-
2793/* In the following three macros, `token' is always last_read_token */-
2794-
2795/* Are we in the middle of parsing a redirection where we are about to read-
2796 a word? This is used to make sure alias expansion doesn't happen in the-
2797 middle of a redirection, even though we're parsing a simple command. */-
2798#define parsing_redirection(token) \-
2799 (token == '<' || token == '>' || \-
2800 token == GREATER_GREATER || token == GREATER_BAR || \-
2801 token == LESS_GREATER || token == LESS_LESS_MINUS || \-
2802 token == LESS_LESS || token == LESS_LESS_LESS || \-
2803 token == LESS_AND || token == GREATER_AND || token == AND_GREATER)-
2804-
2805/* Is `token' one that will allow a WORD to be read in a command position?-
2806 We can read a simple command name on which we should attempt alias expansion-
2807 or we can read an assignment statement. */-
2808#define command_token_position(token) \-
2809 (((token) == ASSIGNMENT_WORD) || \-
2810 ((parser_state&PST_REDIRLIST) && parsing_redirection(token) == 0) || \-
2811 ((token) != SEMI_SEMI && (token) != SEMI_AND && (token) != SEMI_SEMI_AND && reserved_word_acceptable(token)))-
2812-
2813/* Are we in a position where we can read an assignment statement? */-
2814#define assignment_acceptable(token) \-
2815 (command_token_position(token) && ((parser_state & PST_CASEPAT) == 0))-
2816-
2817/* Check to see if TOKEN is a reserved word and return the token-
2818 value if it is. */-
2819#define CHECK_FOR_RESERVED_WORD(tok) \-
2820 do { \-
2821 if (!dollar_present && !quoted && \-
2822 reserved_word_acceptable (last_read_token)) \-
2823 { \-
2824 int i; \-
2825 for (i = 0; word_token_alist[i].word != (char *)NULL; i++) \-
2826 if (STREQ (tok, word_token_alist[i].word)) \-
2827 { \-
2828 if ((parser_state & PST_CASEPAT) && (word_token_alist[i].token != ESAC)) \-
2829 break; \-
2830 if (word_token_alist[i].token == TIME && time_command_acceptable () == 0) \-
2831 break; \-
2832 if ((parser_state & PST_CASEPAT) && last_read_token == '|' && word_token_alist[i].token == ESAC) \-
2833 break; /* Posix grammar rule 4 */ \-
2834 if (word_token_alist[i].token == ESAC) \-
2835 parser_state &= ~(PST_CASEPAT|PST_CASESTMT); \-
2836 else if (word_token_alist[i].token == CASE) \-
2837 parser_state |= PST_CASESTMT; \-
2838 else if (word_token_alist[i].token == COND_END) \-
2839 parser_state &= ~(PST_CONDCMD|PST_CONDEXPR); \-
2840 else if (word_token_alist[i].token == COND_START) \-
2841 parser_state |= PST_CONDCMD; \-
2842 else if (word_token_alist[i].token == '{') \-
2843 open_brace_count++; \-
2844 else if (word_token_alist[i].token == '}' && open_brace_count) \-
2845 open_brace_count--; \-
2846 return (word_token_alist[i].token); \-
2847 } \-
2848 } \-
2849 } while (0)-
2850-
2851#if defined (ALIAS)-
2852-
2853 /* OK, we have a token. Let's try to alias expand it, if (and only if)-
2854 it's eligible.-
2855-
2856 It is eligible for expansion if EXPAND_ALIASES is set, and-
2857 the token is unquoted and the last token read was a command-
2858 separator (or expand_next_token is set), and we are currently-
2859 processing an alias (pushed_string_list is non-empty) and this-
2860 token is not the same as the current or any previously-
2861 processed alias.-
2862-
2863 Special cases that disqualify:-
2864 In a pattern list in a case statement (parser_state & PST_CASEPAT). */-
2865-
2866static char *-
2867mk_alexpansion (s)-
2868 char *s;-
2869{-
2870 int l;-
2871 char *r;-
2872-
2873 l = strlen (s);-
2874 r = xmalloc (l + 2);-
2875 strcpy (r, s);-
2876#ifdef OLD_ALIAS_HACK-
2877 /* If the last character in the alias is a newline, don't add a trailing-
2878 space to the expansion. Works with shell_getc above. */-
2879 /* Need to do something about the case where the alias expansion contains-
2880 an unmatched quoted string, since appending this space affects the-
2881 subsequent output. */-
2882 if (l > 0 && r[l - 1] != ' ' && r[l - 1] != '\n' && shellmeta(r[l - 1]) == 0)-
2883 r[l++] = ' ';-
2884#endif-
2885 r[l] = '\0';-
2886 return r;
executed 82 times by 1 test: return r;
Executed by:
  • Self test
82
2887}-
2888-
2889static int-
2890alias_expand_token (tokstr)-
2891 char *tokstr;-
2892{-
2893 char *expanded;-
2894 alias_t *ap;-
2895-
2896 if (((parser_state & PST_ALEXPNEXT) || command_token_position (last_read_token)) &&
(parser_state & 0x000002)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16237 times by 1 test
Evaluated by:
  • Self test
((last_read_token) == 282)Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16183 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x080000)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16170 times by 1 test
Evaluated by:
  • Self test
(last_read_tok...n == 299) == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_read_token == '<'Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == '>'Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 290Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 302Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 301Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 298Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 291Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 293Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
last_read_token == 299Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
(last_read_token) != 295Description
TRUEevaluated 16170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 296Description
TRUEevaluated 16170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 297Description
TRUEevaluated 16170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
reserved_word_...st_read_token)Description
TRUEevaluated 7277 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8893 times by 1 test
Evaluated by:
  • Self test
0-16237
2897 (parser_state & PST_CASEPAT) == 0)
(parser_state & 0x000001) == 0Description
TRUEevaluated 7139 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 210 times by 1 test
Evaluated by:
  • Self test
210-7139
2898 {-
2899 ap = find_alias (tokstr);-
2900-
2901 /* Currently expanding this token. */-
2902 if (ap && (ap->flags & AL_BEINGEXPANDED))
apDescription
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7042 times by 1 test
Evaluated by:
  • Self test
(ap->flags & 0x2)Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
15-7042
2903 return (NO_EXPANSION);
executed 15 times by 1 test: return (-100);
Executed by:
  • Self test
15
2904-
2905#ifdef OLD_ALIAS_HACK-
2906 /* mk_alexpansion puts an extra space on the end of the alias expansion,-
2907 so the lookahead by the parser works right (the alias needs to remain-
2908 `in use' while parsing its last word to avoid alias recursion for-
2909 something like "alias echo=echo"). If this gets changed, make sure-
2910 the code in shell_getc that deals with reaching the end of an-
2911 expanded alias is changed with it. */-
2912#endif-
2913 expanded = ap ? mk_alexpansion (ap->value) : (char *)NULL;
apDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7042 times by 1 test
Evaluated by:
  • Self test
82-7042
2914-
2915 if (expanded)
expandedDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7042 times by 1 test
Evaluated by:
  • Self test
82-7042
2916 {-
2917 push_string (expanded, ap->flags & AL_EXPANDNEXT, ap);-
2918 return (RE_READ_TOKEN);
executed 82 times by 1 test: return (-99);
Executed by:
  • Self test
82
2919 }-
2920 else-
2921 /* This is an eligible token that does not have an expansion. */-
2922 return (NO_EXPANSION);
executed 7042 times by 1 test: return (-100);
Executed by:
  • Self test
7042
2923 }-
2924 return (NO_EXPANSION);
executed 9103 times by 1 test: return (-100);
Executed by:
  • Self test
9103
2925}-
2926#endif /* ALIAS */-
2927-
2928static int-
2929time_command_acceptable ()-
2930{-
2931#if defined (COMMAND_TIMING)-
2932 int i;-
2933-
2934 if (posixly_correct && shell_compatibility_level > 41)
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
shell_compatibility_level > 41Description
TRUEnever evaluated
FALSEnever evaluated
0-15
2935 {-
2936 /* Quick check of the rest of the line to find the next token. If it-
2937 begins with a `-', Posix says to not return `time' as the token.-
2938 This was interp 267. */-
2939 i = shell_input_line_index;-
2940 while (i < shell_input_line_len && (shell_input_line[i] == ' ' || shell_input_line[i] == '\t'))
i < shell_input_line_lenDescription
TRUEnever evaluated
FALSEnever evaluated
shell_input_line[i] == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
shell_input_line[i] == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
2941 i++;
never executed: i++;
0
2942 if (shell_input_line[i] == '-')
shell_input_line[i] == '-'Description
TRUEnever evaluated
FALSEnever evaluated
0
2943 return 0;
never executed: return 0;
0
2944 }
never executed: end of block
0
2945-
2946 switch (last_read_token)-
2947 {-
2948 case 0:
never executed: case 0:
0
2949 case ';':
never executed: case ';':
0
2950 case '\n':
executed 6 times by 1 test: case '\n':
Executed by:
  • Self test
6
2951 if (token_before_that == '|')
token_before_that == '|'Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-6
2952 return (0);
never executed: return (0);
0
2953 /* FALLTHROUGH */-
2954 case AND_AND:
code before this statement executed 6 times by 1 test: case 288:
Executed by:
  • Self test
never executed: case 288:
0-6
2955 case OR_OR:
never executed: case 289:
0
2956 case '&':
never executed: case '&':
0
2957 case WHILE:
never executed: case 267:
0
2958 case DO:
never executed: case 269:
0
2959 case UNTIL:
never executed: case 268:
0
2960 case IF:
never executed: case 258:
0
2961 case THEN:
never executed: case 259:
0
2962 case ELIF:
never executed: case 261:
0
2963 case ELSE:
never executed: case 260:
0
2964 case '{': /* } */
executed 5 times by 1 test: case '{':
Executed by:
  • Self test
5
2965 case '(': /* )( */
never executed: case '(':
0
2966 case ')': /* only valid in case statement */
never executed: case ')':
0
2967 case BANG: /* ! time pipeline */
executed 1 time by 1 test: case 277:
Executed by:
  • Self test
1
2968 case TIME: /* time time pipeline */
executed 2 times by 1 test: case 278:
Executed by:
  • Self test
2
2969 case TIMEOPT: /* time -p time pipeline */
executed 1 time by 1 test: case 279:
Executed by:
  • Self test
1
2970 case TIMEIGN: /* time -p -- ... */
never executed: case 280:
0
2971 return 1;
executed 15 times by 1 test: return 1;
Executed by:
  • Self test
15
2972 default:
never executed: default:
0
2973 return 0;
never executed: return 0;
0
2974 }-
2975#else-
2976 return 0;-
2977#endif /* COMMAND_TIMING */-
2978}-
2979-
2980/* Handle special cases of token recognition:-
2981 IN is recognized if the last token was WORD and the token-
2982 before that was FOR or CASE or SELECT.-
2983-
2984 DO is recognized if the last token was WORD and the token-
2985 before that was FOR or SELECT.-
2986-
2987 ESAC is recognized if the last token caused `esacs_needed_count'-
2988 to be set-
2989-
2990 `{' is recognized if the last token as WORD and the token-
2991 before that was FUNCTION, or if we just parsed an arithmetic-
2992 `for' command.-
2993-
2994 `}' is recognized if there is an unclosed `{' present.-
2995-
2996 `-p' is returned as TIMEOPT if the last read token was TIME.-
2997 `--' is returned as TIMEIGN if the last read token was TIMEOPT.-
2998-
2999 ']]' is returned as COND_END if the parser is currently parsing-
3000 a conditional expression ((parser_state & PST_CONDEXPR) != 0)-
3001-
3002 `time' is returned as TIME if and only if it is immediately-
3003 preceded by one of `;', `\n', `||', `&&', or `&'.-
3004*/-
3005-
3006static int-
3007special_case_tokens (tokstr)-
3008 char *tokstr;-
3009{-
3010 /* Posix grammar rule 6 */-
3011 if ((last_read_token == WORD) &&
(last_read_token == 281)Description
TRUEevaluated 1185963 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1661044 times by 1 test
Evaluated by:
  • Self test
1185963-1661044
3012 ((token_before_that == FOR) || (token_before_that == CASE) || (token_before_that == SELECT)) &&
(token_before_that == 265)Description
TRUEevaluated 25656 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1160307 times by 1 test
Evaluated by:
  • Self test
(token_before_that == 263)Description
TRUEevaluated 78110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1082197 times by 1 test
Evaluated by:
  • Self test
(token_before_that == 266)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1082190 times by 1 test
Evaluated by:
  • Self test
7-1160307
3013 (tokstr[0] == 'i' && tokstr[1] == 'n' && tokstr[2] == 0))
tokstr[0] == 'i'Description
TRUEevaluated 103770 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == 'n'Description
TRUEevaluated 103770 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[2] == 0Description
TRUEevaluated 103770 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-103770
3014 {-
3015 if (token_before_that == CASE)
token_before_that == 263Description
TRUEevaluated 78109 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25661 times by 1 test
Evaluated by:
  • Self test
25661-78109
3016 {-
3017 parser_state |= PST_CASEPAT;-
3018 esacs_needed_count++;-
3019 }
executed 78109 times by 1 test: end of block
Executed by:
  • Self test
78109
3020 if (expecting_in_token)
expecting_in_tokenDescription
TRUEevaluated 103770 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-103770
3021 expecting_in_token--;
executed 103770 times by 1 test: expecting_in_token--;
Executed by:
  • Self test
103770
3022 return (IN);
executed 103770 times by 1 test: return (276);
Executed by:
  • Self test
103770
3023 }-
3024-
3025 /* bash-5.0: leaving above code intact for now, but it should eventually be-
3026 removed in favor of this clause. */-
3027 /* Posix grammar rule 6 */-
3028 if (expecting_in_token && (last_read_token == WORD || last_read_token == '\n') &&
expecting_in_tokenDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2743228 times by 1 test
Evaluated by:
  • Self test
last_read_token == 281Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
last_read_token == '\n'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
2-2743228
3029 (tokstr[0] == 'i' && tokstr[1] == 'n' && tokstr[2] == 0))
tokstr[0] == 'i'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == 'n'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[2] == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
3030 {-
3031 if (parser_state & PST_CASESTMT)
parser_state & 0x000080Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
3032 {-
3033 parser_state |= PST_CASEPAT;-
3034 esacs_needed_count++;-
3035 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
3036 expecting_in_token--;-
3037 return (IN);
executed 2 times by 1 test: return (276);
Executed by:
  • Self test
2
3038 }-
3039 /* Posix grammar rule 6, third word in FOR: for i; do command-list; done */-
3040 else if (expecting_in_token && (last_read_token == '\n' || last_read_token == ';') &&
expecting_in_tokenDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2743228 times by 1 test
Evaluated by:
  • Self test
last_read_token == '\n'Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
last_read_token == ';'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-2743228
3041 (tokstr[0] == 'd' && tokstr[1] == 'o' && tokstr[2] == '\0'))
tokstr[0] == 'd'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[1] == 'o'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[2] == '\0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
3042 {-
3043 expecting_in_token--;-
3044 return (DO);
executed 4 times by 1 test: return (269);
Executed by:
  • Self test
4
3045 }-
3046-
3047 /* for i do; command-list; done */-
3048 if (last_read_token == WORD &&
last_read_token == 281Description
TRUEevaluated 1082193 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1661038 times by 1 test
Evaluated by:
  • Self test
1082193-1661038
3049#if defined (SELECT_COMMAND)-
3050 (token_before_that == FOR || token_before_that == SELECT) &&
token_before_that == 265Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1082192 times by 1 test
Evaluated by:
  • Self test
token_before_that == 266Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1082191 times by 1 test
Evaluated by:
  • Self test
1-1082192
3051#else-
3052 (token_before_that == FOR) &&-
3053#endif-
3054 (tokstr[0] == 'd' && tokstr[1] == 'o' && tokstr[2] == '\0'))
tokstr[0] == 'd'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[1] == 'o'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[2] == '\0'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
3055 {-
3056 if (expecting_in_token)
expecting_in_tokenDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
3057 expecting_in_token--;
executed 2 times by 1 test: expecting_in_token--;
Executed by:
  • Self test
2
3058 return (DO);
executed 2 times by 1 test: return (269);
Executed by:
  • Self test
2
3059 }-
3060-
3061 /* Ditto for ESAC in the CASE case.-
3062 Specifically, this handles "case word in esac", which is a legal-
3063 construct, certainly because someone will pass an empty arg to the-
3064 case construct, and we don't want it to barf. Of course, we should-
3065 insist that the case construct has at least one pattern in it, but-
3066 the designers disagree. */-
3067 if (esacs_needed_count)
esacs_needed_countDescription
TRUEevaluated 904463 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1838766 times by 1 test
Evaluated by:
  • Self test
904463-1838766
3068 {-
3069 if (last_read_token == IN && STREQ (tokstr, "esac"))
never executed: __result = (((const unsigned char *) (const char *) ( tokstr ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "esac" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
last_read_token == 276Description
TRUEevaluated 23251 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 881212 times by 1 test
Evaluated by:
  • Self test
(tokstr)[0] == ("esac")[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23249 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 2 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-881212
3070 {-
3071 esacs_needed_count--;-
3072 parser_state &= ~PST_CASEPAT;-
3073 return (ESAC);
executed 2 times by 1 test: return (264);
Executed by:
  • Self test
2
3074 }-
3075 }
executed 904461 times by 1 test: end of block
Executed by:
  • Self test
904461
3076-
3077 /* The start of a shell function definition. */-
3078 if (parser_state & PST_ALLOWOPNBRC)
parser_state & 0x000004Description
TRUEevaluated 11217 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2732010 times by 1 test
Evaluated by:
  • Self test
11217-2732010
3079 {-
3080 parser_state &= ~PST_ALLOWOPNBRC;-
3081 if (tokstr[0] == '{' && tokstr[1] == '\0') /* } */
tokstr[0] == '{'Description
TRUEevaluated 11201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == '\0'Description
TRUEevaluated 11201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11201
3082 {-
3083 open_brace_count++;-
3084 function_bstart = line_number;-
3085 return ('{'); /* } */
executed 11201 times by 1 test: return ('{');
Executed by:
  • Self test
11201
3086 }-
3087 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
3088-
3089 /* We allow a `do' after a for ((...)) without an intervening-
3090 list_terminator */-
3091 if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == 'd' && tokstr[1] == 'o' && !tokstr[2])
last_read_token == 286Description
TRUEevaluated 402 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2731624 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == 'd'Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 201 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == 'o'Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!tokstr[2]Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2731624
3092 return (DO);
executed 201 times by 1 test: return (269);
Executed by:
  • Self test
201
3093 if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == '{' && tokstr[1] == '\0') /* } */
last_read_token == 286Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2731624 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == '{'Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[1] == '\0'Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2731624
3094 {-
3095 open_brace_count++;-
3096 return ('{'); /* } */
executed 201 times by 1 test: return ('{');
Executed by:
  • Self test
201
3097 }-
3098-
3099 if (open_brace_count && reserved_word_acceptable (last_read_token) && tokstr[0] == '}' && !tokstr[1])
open_brace_countDescription
TRUEevaluated 490215 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2241409 times by 1 test
Evaluated by:
  • Self test
reserved_word_...st_read_token)Description
TRUEevaluated 351427 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 138788 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == '}'Description
TRUEevaluated 12223 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 339204 times by 1 test
Evaluated by:
  • Self test
!tokstr[1]Description
TRUEevaluated 12223 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2241409
3100 {-
3101 open_brace_count--; /* { */-
3102 return ('}');
executed 12223 times by 1 test: return ('}');
Executed by:
  • Self test
12223
3103 }-
3104-
3105#if defined (COMMAND_TIMING)-
3106 /* Handle -p after `time'. */-
3107 if (last_read_token == TIME && tokstr[0] == '-' && tokstr[1] == 'p' && !tokstr[2])
last_read_token == 278Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2719387 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == '-'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == 'p'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!tokstr[2]Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2719387
3108 return (TIMEOPT);
executed 8 times by 1 test: return (279);
Executed by:
  • Self test
8
3109 /* Handle -- after `time -p'. */-
3110 if (last_read_token == TIMEOPT && tokstr[0] == '-' && tokstr[1] == '-' && !tokstr[2])
last_read_token == 279Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2719385 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == '-'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == '-'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!tokstr[2]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2719385
3111 return (TIMEIGN);
executed 1 time by 1 test: return (280);
Executed by:
  • Self test
1
3112#endif-
3113-
3114#if defined (COND_COMMAND) /* [[ */-
3115 if ((parser_state & PST_CONDEXPR) && tokstr[0] == ']' && tokstr[1] == ']' && tokstr[2] == '\0')
(parser_state & 0x000200)Description
TRUEevaluated 2338 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2717054 times by 1 test
Evaluated by:
  • Self test
tokstr[0] == ']'Description
TRUEevaluated 574 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1764 times by 1 test
Evaluated by:
  • Self test
tokstr[1] == ']'Description
TRUEevaluated 574 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tokstr[2] == '\0'Description
TRUEevaluated 574 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2717054
3116 return (COND_END);
executed 574 times by 1 test: return (274);
Executed by:
  • Self test
574
3117#endif-
3118-
3119 return (-1);
executed 2718818 times by 1 test: return (-1);
Executed by:
  • Self test
2718818
3120}-
3121-
3122/* Called from shell.c when Control-C is typed at top level. Or-
3123 by the error rule at top level. */-
3124void-
3125reset_parser ()-
3126{-
3127 dstack.delimiter_depth = 0; /* No delimiters found so far. */-
3128 open_brace_count = 0;-
3129-
3130#if defined (EXTENDED_GLOB)-
3131 /* Reset to global value of extended glob */-
3132 if (parser_state & PST_EXTPAT)
parser_state & 0x001000Description
TRUEnever evaluated
FALSEevaluated 705454 times by 1 test
Evaluated by:
  • Self test
0-705454
3133 extended_glob = global_extglob;
never executed: extended_glob = global_extglob;
0
3134#endif-
3135-
3136 parser_state = 0;-
3137 here_doc_first_line = 0;-
3138-
3139#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
3140 if (pushed_string_list)
pushed_string_listDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705452 times by 1 test
Evaluated by:
  • Self test
2-705452
3141 free_string_list ();
executed 2 times by 1 test: free_string_list ();
Executed by:
  • Self test
2
3142#endif /* ALIAS || DPAREN_ARITHMETIC */-
3143-
3144 /* This is where we resynchronize to the next newline on error/reset */-
3145 if (shell_input_line)
shell_input_lineDescription
TRUEevaluated 705447 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7-705447
3146 {-
3147 free (shell_input_line);-
3148 shell_input_line = (char *)NULL;-
3149 shell_input_line_size = shell_input_line_index = 0;-
3150 }
executed 705447 times by 1 test: end of block
Executed by:
  • Self test
705447
3151-
3152 FREE (word_desc_to_read);
never executed: sh_xfree((word_desc_to_read), "./parse.y", 3152);
word_desc_to_readDescription
TRUEnever evaluated
FALSEevaluated 705454 times by 1 test
Evaluated by:
  • Self test
0-705454
3153 word_desc_to_read = (WORD_DESC *)NULL;-
3154-
3155 eol_ungetc_lookahead = 0;-
3156-
3157 current_token = '\n'; /* XXX */-
3158 last_read_token = '\n';-
3159 token_to_read = '\n';-
3160}
executed 705454 times by 1 test: end of block
Executed by:
  • Self test
705454
3161-
3162/* Read the next token. Command can be READ (normal operation) or-
3163 RESET (to normalize state). */-
3164static int-
3165read_token (command)-
3166 int command;-
3167{-
3168 int character; /* Current character. */-
3169 int peek_char; /* Temporary look-ahead character. */-
3170 int result; /* The thing to return. */-
3171-
3172 if (command == RESET)
command == 1Description
TRUEnever evaluated
FALSEevaluated 4839811 times by 1 test
Evaluated by:
  • Self test
0-4839811
3173 {-
3174 reset_parser ();-
3175 return ('\n');
never executed: return ('\n');
0
3176 }-
3177-
3178 if (token_to_read)
token_to_readDescription
TRUEevaluated 720 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4839091 times by 1 test
Evaluated by:
  • Self test
720-4839091
3179 {-
3180 result = token_to_read;-
3181 if (token_to_read == WORD || token_to_read == ASSIGNMENT_WORD)
token_to_read == 281Description
TRUEnever evaluated
FALSEevaluated 720 times by 1 test
Evaluated by:
  • Self test
token_to_read == 282Description
TRUEnever evaluated
FALSEevaluated 720 times by 1 test
Evaluated by:
  • Self test
0-720
3182 {-
3183 yylval.word = word_desc_to_read;-
3184 word_desc_to_read = (WORD_DESC *)NULL;-
3185 }
never executed: end of block
0
3186 token_to_read = 0;-
3187 return (result);
executed 720 times by 1 test: return (result);
Executed by:
  • Self test
720
3188 }-
3189-
3190#if defined (COND_COMMAND)-
3191 if ((parser_state & (PST_CONDCMD|PST_CONDEXPR)) == PST_CONDCMD)
(parser_state ...)) == 0x000100Description
TRUEevaluated 574 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4838517 times by 1 test
Evaluated by:
  • Self test
574-4838517
3192 {-
3193 cond_lineno = line_number;-
3194 parser_state |= PST_CONDEXPR;-
3195 yylval.command = parse_cond_command ();-
3196 if (cond_token != COND_END)
cond_token != 274Description
TRUEnever evaluated
FALSEevaluated 574 times by 1 test
Evaluated by:
  • Self test
0-574
3197 {-
3198 cond_error ();-
3199 return (-1);
never executed: return (-1);
0
3200 }-
3201 token_to_read = COND_END;-
3202 parser_state &= ~(PST_CONDEXPR|PST_CONDCMD);-
3203 return (COND_CMD);
executed 574 times by 1 test: return (287);
Executed by:
  • Self test
574
3204 }-
3205#endif-
3206-
3207#if defined (ALIAS)-
3208 /* This is a place to jump back to once we have successfully expanded a-
3209 token with an alias and pushed the string with push_string () */-
3210 re_read_token:
code before this statement executed 4838517 times by 1 test: re_read_token:
Executed by:
  • Self test
4838517
3211#endif /* ALIAS */-
3212-
3213 /* Read a single word from input. Start by skipping blanks. */-
3214 while ((character = shell_getc (1)) != EOF && shellblank (character))
(character = s...c (1)) != (-1)Description
TRUEevaluated 8083881 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 361 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...er)] & 0x2000)Description
TRUEevaluated 3245643 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4838238 times by 1 test
Evaluated by:
  • Self test
361-8083881
3215 ;
executed 3245643 times by 1 test: ;
Executed by:
  • Self test
3245643
3216-
3217 if (character == EOF)
character == (-1)Description
TRUEevaluated 361 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4838238 times by 1 test
Evaluated by:
  • Self test
361-4838238
3218 {-
3219 EOF_Reached = 1;-
3220 return (yacc_EOF);
executed 361 times by 1 test: return (304);
Executed by:
  • Self test
361
3221 }-
3222-
3223 /* If we hit the end of the string and we're not expanding an alias (e.g.,-
3224 we are eval'ing a string that is an incomplete command), return EOF */-
3225 if (character == '\0' && bash_input.type == st_string && expanding_alias() == 0)
character == '\0'Description
TRUEnever evaluated
FALSEevaluated 4838238 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stringDescription
TRUEnever evaluated
FALSEnever evaluated
(pushed_string...expander) == 0Description
TRUEnever evaluated
FALSEnever evaluated
pushed_string_listDescription
TRUEnever evaluated
FALSEnever evaluated
pushed_string_list->expanderDescription
TRUEnever evaluated
FALSEnever evaluated
0-4838238
3226 {-
3227#if defined (DEBUG)-
3228itrace("shell_getc: bash_input.location.string = `%s'", bash_input.location.string);-
3229#endif-
3230 EOF_Reached = 1;-
3231 return (yacc_EOF);
never executed: return (304);
0
3232 }-
3233-
3234 if MBTEST(character == '#' && (!interactive || interactive_comments))
(shell_input_line_index > 1)Description
TRUEevaluated 1465 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34011 times by 1 test
Evaluated by:
  • Self test
character == '#'Description
TRUEevaluated 35476 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4802762 times by 1 test
Evaluated by:
  • Self test
!interactiveDescription
TRUEevaluated 35476 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
interactive_commentsDescription
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 35476 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4802762
3235 {-
3236 /* A comment. Discard until EOL or EOF, and then return a newline. */-
3237 discard_until ('\n');-
3238 shell_getc (0);-
3239 character = '\n'; /* this will take the next if statement and return. */-
3240 }
executed 35476 times by 1 test: end of block
Executed by:
  • Self test
35476
3241-
3242 if (character == '\n')
character == '\n'Description
TRUEevaluated 716846 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4121392 times by 1 test
Evaluated by:
  • Self test
716846-4121392
3243 {-
3244 /* If we're about to return an unquoted newline, we can go and collect-
3245 the text of any pending here document. */-
3246 if (need_here_doc)
need_here_docDescription
TRUEevaluated 1726 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 715120 times by 1 test
Evaluated by:
  • Self test
1726-715120
3247 gather_here_documents ();
executed 1726 times by 1 test: gather_here_documents ();
Executed by:
  • Self test
1726
3248-
3249#if defined (ALIAS)-
3250 parser_state &= ~PST_ALEXPNEXT;-
3251#endif /* ALIAS */-
3252-
3253 parser_state &= ~PST_ASSIGNOK;-
3254-
3255 return (character);
executed 716846 times by 1 test: return (character);
Executed by:
  • Self test
716846
3256 }-
3257-
3258 if (parser_state & PST_REGEXP)
parser_state & 0x010000Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4121301 times by 1 test
Evaluated by:
  • Self test
91-4121301
3259 goto tokword;
executed 91 times by 1 test: goto tokword;
Executed by:
  • Self test
91
3260-
3261 /* Shell meta-characters. */-
3262 if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
(shell_input_line_index > 1)Description
TRUEevaluated 1257549 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4739 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...er)] & 0x0001)Description
TRUEevaluated 1262288 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2859013 times by 1 test
Evaluated by:
  • Self test
((parser_state...x000010) == 0)Description
TRUEevaluated 1262288 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 1262288 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2859013
3263 {-
3264#if defined (ALIAS)-
3265 /* Turn off alias tokenization iff this character sequence would-
3266 not leave us ready to read a command. */-
3267 if (character == '<' || character == '>')
character == '<'Description
TRUEevaluated 18723 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1243565 times by 1 test
Evaluated by:
  • Self test
character == '>'Description
TRUEevaluated 35988 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1207577 times by 1 test
Evaluated by:
  • Self test
18723-1243565
3268 parser_state &= ~PST_ALEXPNEXT;
executed 54711 times by 1 test: parser_state &= ~0x000002;
Executed by:
  • Self test
54711
3269#endif /* ALIAS */-
3270-
3271 parser_state &= ~PST_ASSIGNOK;-
3272-
3273 /* If we are parsing a command substitution and we have read a character-
3274 that marks the end of it, don't bother to skip over quoted newlines-
3275 when we read the next token. We're just interested in a character-
3276 that will turn this into a two-character token, so we let the higher-
3277 layers deal with quoted newlines following the command substitution. */-
3278 if ((parser_state & PST_CMDSUBST) && character == shell_eof_token)
(parser_state & 0x000040)Description
TRUEevaluated 791139 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 471149 times by 1 test
Evaluated by:
  • Self test
character == shell_eof_tokenDescription
TRUEevaluated 705861 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 85278 times by 1 test
Evaluated by:
  • Self test
85278-791139
3279 peek_char = shell_getc (0);
executed 705861 times by 1 test: peek_char = shell_getc (0);
Executed by:
  • Self test
705861
3280 else-
3281 peek_char = shell_getc (1);
executed 556427 times by 1 test: peek_char = shell_getc (1);
Executed by:
  • Self test
556427
3282-
3283 if (character == peek_char)
character == peek_charDescription
TRUEevaluated 229852 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1032436 times by 1 test
Evaluated by:
  • Self test
229852-1032436
3284 {-
3285 switch (character)-
3286 {-
3287 case '<':
executed 1816 times by 1 test: case '<':
Executed by:
  • Self test
1816
3288 /* If '<' then we could be at "<<" or at "<<-". We have to-
3289 look ahead one more character. */-
3290 peek_char = shell_getc (1);-
3291 if MBTEST(peek_char == '-')
(shell_input_line_index > 1)Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '-')Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1778 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1778
3292 return (LESS_LESS_MINUS);
executed 38 times by 1 test: return (298);
Executed by:
  • Self test
38
3293 else if MBTEST(peek_char == '<')
(shell_input_line_index > 1)Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '<')Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1713 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1713
3294 return (LESS_LESS_LESS);
executed 65 times by 1 test: return (293);
Executed by:
  • Self test
65
3295 else-
3296 {-
3297 shell_ungetc (peek_char);-
3298 return (LESS_LESS);
executed 1713 times by 1 test: return (291);
Executed by:
  • Self test
1713
3299 }-
3300-
3301 case '>':
executed 33 times by 1 test: case '>':
Executed by:
  • Self test
33
3302 return (GREATER_GREATER);
executed 33 times by 1 test: return (290);
Executed by:
  • Self test
33
3303-
3304 case ';':
executed 155759 times by 1 test: case ';':
Executed by:
  • Self test
155759
3305 parser_state |= PST_CASEPAT;-
3306#if defined (ALIAS)-
3307 parser_state &= ~PST_ALEXPNEXT;-
3308#endif /* ALIAS */-
3309-
3310 peek_char = shell_getc (1);-
3311 if MBTEST(peek_char == '&')
(shell_input_line_index > 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '&')Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 155757 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-155757
3312 return (SEMI_SEMI_AND);
executed 2 times by 1 test: return (297);
Executed by:
  • Self test
2
3313 else-
3314 {-
3315 shell_ungetc (peek_char);-
3316 return (SEMI_SEMI);
executed 155757 times by 1 test: return (295);
Executed by:
  • Self test
155757
3317 }-
3318-
3319 case '&':
executed 700 times by 1 test: case '&':
Executed by:
  • Self test
700
3320 return (AND_AND);
executed 700 times by 1 test: return (288);
Executed by:
  • Self test
700
3321-
3322 case '|':
executed 21714 times by 1 test: case '|':
Executed by:
  • Self test
21714
3323 return (OR_OR);
executed 21714 times by 1 test: return (289);
Executed by:
  • Self test
21714
3324-
3325#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)-
3326 case '(': /* ) */
executed 49738 times by 1 test: case '(':
Executed by:
  • Self test
49738
3327 result = parse_dparen (character);-
3328 if (result == -2)
result == -2Description
TRUEnever evaluated
FALSEevaluated 49738 times by 1 test
Evaluated by:
  • Self test
0-49738
3329 break;
never executed: break;
0
3330 else-
3331 return result;
executed 49738 times by 1 test: return result;
Executed by:
  • Self test
49738
3332#endif-
3333 }-
3334 }
executed 92 times by 1 test: end of block
Executed by:
  • Self test
92
3335 else if MBTEST(character == '<' && peek_char == '&')
(shell_input_line_index > 1)Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '<'Description
TRUEevaluated 16907 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1015529 times by 1 test
Evaluated by:
  • Self test
peek_char == '&'Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16831 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1015529
3336 return (LESS_AND);
executed 76 times by 1 test: return (292);
Executed by:
  • Self test
76
3337 else if MBTEST(character == '>' && peek_char == '&')
(shell_input_line_index > 1)Description
TRUEevaluated 22403 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '>'Description
TRUEevaluated 35955 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 996405 times by 1 test
Evaluated by:
  • Self test
peek_char == '&'Description
TRUEevaluated 22403 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13552 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 22403 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-996405
3338 return (GREATER_AND);
executed 22403 times by 1 test: return (294);
Executed by:
  • Self test
22403
3339 else if MBTEST(character == '<' && peek_char == '>')
(shell_input_line_index > 1)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '<'Description
TRUEevaluated 16831 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 993126 times by 1 test
Evaluated by:
  • Self test
peek_char == '>'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16811 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-993126
3340 return (LESS_GREATER);
executed 20 times by 1 test: return (301);
Executed by:
  • Self test
20
3341 else if MBTEST(character == '>' && peek_char == '|')
(shell_input_line_index > 1)Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '>'Description
TRUEevaluated 13552 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 996385 times by 1 test
Evaluated by:
  • Self test
peek_char == '|'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13533 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-996385
3342 return (GREATER_BAR);
executed 19 times by 1 test: return (302);
Executed by:
  • Self test
19
3343 else if MBTEST(character == '&' && peek_char == '>')
(shell_input_line_index > 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '&'Description
TRUEevaluated 346 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1009572 times by 1 test
Evaluated by:
  • Self test
peek_char == '>'Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 324 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1009572
3344 {-
3345 peek_char = shell_getc (1);-
3346 if MBTEST(peek_char == '>')
(shell_input_line_index > 1)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '>')Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-18
3347 return (AND_GREATER_GREATER);
executed 4 times by 1 test: return (300);
Executed by:
  • Self test
4
3348 else-
3349 {-
3350 shell_ungetc (peek_char);-
3351 return (AND_GREATER);
executed 18 times by 1 test: return (299);
Executed by:
  • Self test
18
3352 }-
3353 }-
3354 else if MBTEST(character == '|' && peek_char == '&')
(shell_input_line_index > 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '|'Description
TRUEevaluated 20453 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 989443 times by 1 test
Evaluated by:
  • Self test
peek_char == '&'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20451 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-989443
3355 return (BAR_AND);
executed 2 times by 1 test: return (303);
Executed by:
  • Self test
2
3356 else if MBTEST(character == ';' && peek_char == '&')
(shell_input_line_index > 1)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == ';'Description
TRUEevaluated 59362 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 950532 times by 1 test
Evaluated by:
  • Self test
peek_char == '&'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59358 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-950532
3357 {-
3358 parser_state |= PST_CASEPAT;-
3359#if defined (ALIAS)-
3360 parser_state &= ~PST_ALEXPNEXT;-
3361#endif /* ALIAS */-
3362 return (SEMI_AND);
executed 4 times by 1 test: return (296);
Executed by:
  • Self test
4
3363 }-
3364-
3365 shell_ungetc (peek_char);-
3366-
3367 /* If we look like we are reading the start of a function-
3368 definition, then let the reader know about it so that-
3369 we will do the right thing with `{'. */-
3370 if MBTEST(character == ')' && last_read_token == '(' && token_before_that == WORD)
(shell_input_line_index > 1)Description
TRUEevaluated 11196 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == ')'Description
TRUEevaluated 881455 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 128527 times by 1 test
Evaluated by:
  • Self test
last_read_token == '('Description
TRUEevaluated 11196 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 870259 times by 1 test
Evaluated by:
  • Self test
token_before_that == 281Description
TRUEevaluated 11196 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 11196 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-881455
3371 {-
3372 parser_state |= PST_ALLOWOPNBRC;-
3373#if defined (ALIAS)-
3374 parser_state &= ~PST_ALEXPNEXT;-
3375#endif /* ALIAS */-
3376 function_dstart = line_number;-
3377 }
executed 11196 times by 1 test: end of block
Executed by:
  • Self test
11196
3378-
3379 /* case pattern lists may be preceded by an optional left paren. If-
3380 we're not trying to parse a case pattern list, the left paren-
3381 indicates a subshell. */-
3382 if MBTEST(character == '(' && (parser_state & PST_CASEPAT) == 0) /* ) */
(shell_input_line_index > 1)Description
TRUEevaluated 15684 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1482 times by 1 test
Evaluated by:
  • Self test
character == '('Description
TRUEevaluated 18050 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 991932 times by 1 test
Evaluated by:
  • Self test
(parser_state & 0x000001) == 0Description
TRUEevaluated 17166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 884 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 17166 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-991932
3383 parser_state |= PST_SUBSHELL;
executed 17166 times by 1 test: parser_state |= 0x000020;
Executed by:
  • Self test
17166
3384 /*(*/-
3385 else if MBTEST((parser_state & PST_CASEPAT) && character == ')')
(shell_input_line_index > 1)Description
TRUEevaluated 158270 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(parser_state & 0x000001)Description
TRUEevaluated 165984 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 826832 times by 1 test
Evaluated by:
  • Self test
character == ')'Description
TRUEevaluated 158270 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7714 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 158270 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-826832
3386 parser_state &= ~PST_CASEPAT;
executed 158270 times by 1 test: parser_state &= ~0x000001;
Executed by:
  • Self test
158270
3387 /*(*/-
3388 else if MBTEST((parser_state & PST_SUBSHELL) && character == ')')
(shell_input_line_index > 1)Description
TRUEevaluated 17118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
(parser_state & 0x000020)Description
TRUEevaluated 23071 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 811475 times by 1 test
Evaluated by:
  • Self test
character == ')'Description
TRUEevaluated 17155 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5916 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 17155 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-811475
3389 parser_state &= ~PST_SUBSHELL;
executed 17155 times by 1 test: parser_state &= ~0x000020;
Executed by:
  • Self test
17155
3390-
3391#if defined (PROCESS_SUBSTITUTION)-
3392 /* Check for the constructs which introduce process substitution.-
3393 Shells running in `posix mode' don't do process substitution. */-
3394 if MBTEST(posixly_correct || ((character != '>' && character != '<') || peek_char != '(')) /*)*/
(shell_input_line_index > 1)Description
TRUEevaluated 991438 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2368 times by 1 test
Evaluated by:
  • Self test
posixly_correctDescription
TRUEevaluated 2870 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1007112 times by 1 test
Evaluated by:
  • Self test
character != '>'Description
TRUEevaluated 993589 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13523 times by 1 test
Evaluated by:
  • Self test
character != '<'Description
TRUEevaluated 976789 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16800 times by 1 test
Evaluated by:
  • Self test
peek_char != '('Description
TRUEevaluated 14147 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16176 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 993806 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1007112
3395#endif /* PROCESS_SUBSTITUTION */-
3396 return (character);
executed 993806 times by 1 test: return (character);
Executed by:
  • Self test
993806
3397 }
executed 16176 times by 1 test: end of block
Executed by:
  • Self test
16176
3398-
3399 /* Hack <&- (close stdin) case. Also <&N- (dup and close). */-
3400 if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
(shell_input_line_index > 1)Description
TRUEevaluated 1052 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '-'Description
TRUEevaluated 32825 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2842364 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32799 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEevaluated 1026 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31773 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 1052 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2842364
3401 return (character);
executed 1052 times by 1 test: return (character);
Executed by:
  • Self test
1052
3402-
3403tokword:
code before this statement executed 2874137 times by 1 test: tokword:
Executed by:
  • Self test
2874137
3404 /* Okay, if we got this far, we have to read a word. Read one,-
3405 and then check it against the known ones. */-
3406 result = read_token_word (character);-
3407#if defined (ALIAS)-
3408 if (result == RE_READ_TOKEN)
result == -99Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2874129 times by 1 test
Evaluated by:
  • Self test
82-2874129
3409 goto re_read_token;
executed 82 times by 1 test: goto re_read_token;
Executed by:
  • Self test
82
3410#endif-
3411 return result;
executed 2874129 times by 1 test: return result;
Executed by:
  • Self test
2874129
3412}-
3413-
3414/*-
3415 * Match a $(...) or other grouping construct. This has to handle embedded-
3416 * quoted strings ('', ``, "") and nested constructs. It also must handle-
3417 * reprompting the user, if necessary, after reading a newline, and returning-
3418 * correct error values if it reads EOF.-
3419 */-
3420#define P_FIRSTCLOSE 0x0001-
3421#define P_ALLOWESC 0x0002-
3422#define P_DQUOTE 0x0004-
3423#define P_COMMAND 0x0008 /* parsing a command, so look for comments */-
3424#define P_BACKQUOTE 0x0010 /* parsing a backquoted command substitution */-
3425#define P_ARRAYSUB 0x0020 /* parsing a [...] array subscript for assignment */-
3426#define P_DOLBRACE 0x0040 /* parsing a ${...} construct */-
3427-
3428/* Lexical state while parsing a grouping construct or $(...). */-
3429#define LEX_WASDOL 0x0001-
3430#define LEX_CKCOMMENT 0x0002-
3431#define LEX_INCOMMENT 0x0004-
3432#define LEX_PASSNEXT 0x0008-
3433#define LEX_RESWDOK 0x0010-
3434#define LEX_CKCASE 0x0020-
3435#define LEX_INCASE 0x0040-
3436#define LEX_INHEREDOC 0x0080-
3437#define LEX_HEREDELIM 0x0100 /* reading here-doc delimiter */-
3438#define LEX_STRIPDOC 0x0200 /* <<- strip tabs from here doc delim */-
3439#define LEX_QUOTEDDOC 0x0400 /* here doc with quoted delim */-
3440#define LEX_INWORD 0x0800-
3441#define LEX_GTLT 0x1000-
3442-
3443#define COMSUB_META(ch) ((ch) == ';' || (ch) == '&' || (ch) == '|')-
3444-
3445#define CHECK_NESTRET_ERROR() \-
3446 do { \-
3447 if (nestret == &matched_pair_error) \-
3448 { \-
3449 free (ret); \-
3450 return &matched_pair_error; \-
3451 } \-
3452 } while (0)-
3453-
3454#define APPEND_NESTRET() \-
3455 do { \-
3456 if (nestlen) \-
3457 { \-
3458 RESIZE_MALLOCED_BUFFER (ret, retind, nestlen, retsize, 64); \-
3459 strcpy (ret + retind, nestret); \-
3460 retind += nestlen; \-
3461 } \-
3462 } while (0)-
3463-
3464static char matched_pair_error;-
3465-
3466static char *-
3467parse_matched_pair (qc, open, close, lenp, flags)-
3468 int qc; /* `"' if this construct is within double quotes */-
3469 int open, close;-
3470 int *lenp, flags;-
3471{-
3472 int count, ch, prevch, tflags;-
3473 int nestlen, ttranslen, start_lineno;-
3474 char *ret, *nestret, *ttrans;-
3475 int retind, retsize, rflags;-
3476 int dolbrace_state;-
3477-
3478 dolbrace_state = (flags & P_DOLBRACE) ? DOLBRACE_PARAM : 0;
(flags & 0x0040)Description
TRUEevaluated 23686 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 435060 times by 1 test
Evaluated by:
  • Self test
23686-435060
3479-
3480/*itrace("parse_matched_pair[%d]: open = %c close = %c flags = %d", line_number, open, close, flags);*/-
3481 count = 1;-
3482 tflags = 0;-
3483-
3484 if ((flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0)
(flags & 0x0008)Description
TRUEevaluated 26230 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 432516 times by 1 test
Evaluated by:
  • Self test
qc != '`'Description
TRUEnever evaluated
FALSEevaluated 26230 times by 1 test
Evaluated by:
  • Self test
qc != '\''Description
TRUEnever evaluated
FALSEnever evaluated
qc != '"'Description
TRUEnever evaluated
FALSEnever evaluated
(flags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-432516
3485 tflags |= LEX_CKCOMMENT;
never executed: tflags |= 0x0002;
0
3486-
3487 /* RFLAGS is the set of flags we want to pass to recursive calls. */-
3488 rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
(qc == '"')Description
TRUEevaluated 152909 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 305837 times by 1 test
Evaluated by:
  • Self test
152909-305837
3489-
3490 ret = (char *)xmalloc (retsize = 64);-
3491 retind = 0;-
3492-
3493 start_lineno = line_number;-
3494 ch = EOF; /* just in case */-
3495 while (count)
countDescription
TRUEevaluated 3944688 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3944688
3496 {-
3497 prevch = ch;-
3498 ch = shell_getc (qc != '\'' && (tflags & (LEX_PASSNEXT)) == 0);-
3499-
3500 if (ch == EOF)
ch == (-1)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3944687 times by 1 test
Evaluated by:
  • Self test
1-3944687
3501 {-
3502 free (ret);-
3503 parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), close);-
3504 EOF_Reached = 1; /* XXX */-
3505 return (&matched_pair_error);
executed 1 time by 1 test: return (&matched_pair_error);
Executed by:
  • Self test
1
3506 }-
3507-
3508 /* Possible reprompting. */-
3509 if (ch == '\n' && SHOULD_PROMPT ())
ch == '\n'Description
TRUEevaluated 2641 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3942046 times by 1 test
Evaluated by:
  • Self test
interactiveDescription
TRUEnever evaluated
FALSEevaluated 2641 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-3942046
3510 prompt_again ();
never executed: prompt_again ();
0
3511-
3512 /* Don't bother counting parens or doing anything else if in a comment-
3513 or part of a case statement */-
3514 if (tflags & LEX_INCOMMENT)
tflags & 0x0004Description
TRUEnever evaluated
FALSEevaluated 3944687 times by 1 test
Evaluated by:
  • Self test
0-3944687
3515 {-
3516 /* Add this character. */-
3517 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3518 ret[retind++] = ch;-
3519-
3520 if (ch == '\n')
ch == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
3521 tflags &= ~LEX_INCOMMENT;
never executed: tflags &= ~0x0004;
0
3522-
3523 continue;
never executed: continue;
0
3524 }-
3525-
3526 /* Not exactly right yet, should handle shell metacharacters, too. If-
3527 any changes are made to this test, make analogous changes to subst.c:-
3528 extract_delimited_string(). */-
3529 else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || shellblank (ret[retind - 1])))
(shell_input_line_index > 1)Description
TRUEnever evaluated
FALSEnever evaluated
(tflags & 0x0002)Description
TRUEnever evaluated
FALSEevaluated 3944687 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
ch == '#'Description
TRUEnever evaluated
FALSEnever evaluated
retind == 0Description
TRUEnever evaluated
FALSEnever evaluated
ret[retind-1] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
(sh_syntaxtab[...1])] & 0x2000)Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-3944687
3530 tflags |= LEX_INCOMMENT;
never executed: tflags |= 0x0004;
0
3531-
3532 if (tflags & LEX_PASSNEXT) /* last char was backslash */
tflags & 0x0008Description
TRUEevaluated 158319 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3786368 times by 1 test
Evaluated by:
  • Self test
158319-3786368
3533 {-
3534 tflags &= ~LEX_PASSNEXT;-
3535 if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */
qc != '\''Description
TRUEevaluated 153494 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4825 times by 1 test
Evaluated by:
  • Self test
ch == '\n'Description
TRUEnever evaluated
FALSEevaluated 153494 times by 1 test
Evaluated by:
  • Self test
0-153494
3536 {-
3537 if (retind > 0)
retind > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3538 retind--; /* swallow previously-added backslash */
never executed: retind--;
0
3539 continue;
never executed: continue;
0
3540 }-
3541-
3542 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
executed 1 time by 1 test: retsize += (64);
Executed by:
  • Self test
executed 1 time by 1 test: end of block
Executed by:
  • Self test
(retind) + (2) >= retsizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 158318 times by 1 test
Evaluated by:
  • Self test
(retind) + (2) >= retsizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-158318
3543 if MBTEST(ch == CTLESC)
(shell_input_line_index > 1)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(ch == '\001')Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 158309 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-158309
3544 ret[retind++] = CTLESC;
executed 10 times by 1 test: ret[retind++] = '\001';
Executed by:
  • Self test
10
3545 ret[retind++] = ch;-
3546 continue;
executed 158319 times by 1 test: continue;
Executed by:
  • Self test
158319
3547 }-
3548 /* If we're reparsing the input (e.g., from parse_string_to_word_list),-
3549 we've already prepended CTLESC to single-quoted results of $'...'.-
3550 We may want to do this for other CTLESC-quoted characters in-
3551 reparse, too. */-
3552 else if MBTEST((parser_state & PST_REPARSE) && open == '\'' && (ch == CTLESC || ch == CTLNUL))
(shell_input_line_index > 1)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(parser_state & 0x040000)Description
TRUEevaluated 21545 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3764823 times by 1 test
Evaluated by:
  • Self test
open == '\''Description
TRUEevaluated 5833 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15712 times by 1 test
Evaluated by:
  • Self test
ch == '\001'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5814 times by 1 test
Evaluated by:
  • Self test
ch == '\177'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5807 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3764823
3553 {-
3554 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-26
3555 ret[retind++] = ch;-
3556 continue;
executed 26 times by 1 test: continue;
Executed by:
  • Self test
26
3557 }-
3558 else if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */
(shell_input_line_index > 1)Description
TRUEevaluated 429 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '\001'Description
TRUEevaluated 226 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3786116 times by 1 test
Evaluated by:
  • Self test
ch == '\177'Description
TRUEevaluated 203 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3785913 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 429 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3786116
3559 {-
3560 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (2) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 429 times by 1 test
Evaluated by:
  • Self test
(retind) + (2) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-429
3561 ret[retind++] = CTLESC;-
3562 ret[retind++] = ch;-
3563 continue;
executed 429 times by 1 test: continue;
Executed by:
  • Self test
429
3564 }-
3565 else if MBTEST(ch == close) /* ending delimiter */
(shell_input_line_index > 1)Description
TRUEevaluated 461638 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 88 times by 1 test
Evaluated by:
  • Self test
(ch == close)Description
TRUEevaluated 461726 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3324187 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 461726 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3324187
3566 count--;
executed 461726 times by 1 test: count--;
Executed by:
  • Self test
461726
3567 /* handle nested ${...} specially. */-
3568 else if MBTEST(open != close && (tflags & LEX_WASDOL) && open == '{' && ch == open) /* } */
(shell_input_line_index > 1)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
open != closeDescription
TRUEevaluated 588016 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2736171 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0001)Description
TRUEevaluated 5430 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 582586 times by 1 test
Evaluated by:
  • Self test
open == '{'Description
TRUEevaluated 4644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 786 times by 1 test
Evaluated by:
  • Self test
ch == openDescription
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4483 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2736171
3569 count++;
executed 161 times by 1 test: count++;
Executed by:
  • Self test
161
3570 else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && ch == open) /* nested begin */
(shell_input_line_index > 1)Description
TRUEevaluated 2984 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((flags & 0x0001) == 0)Description
TRUEevaluated 3145709 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 178317 times by 1 test
Evaluated by:
  • Self test
ch == openDescription
TRUEevaluated 2984 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3142725 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2984 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3145709
3571 count++;
executed 2984 times by 1 test: count++;
Executed by:
  • Self test
2984
3572-
3573 /* Add this character. */-
3574 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 14045 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 14045 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 14045 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3771868 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 14045 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14045 times by 1 test
Evaluated by:
  • Self test
14045-3771868
3575 ret[retind++] = ch;-
3576-
3577 /* If we just read the ending character, don't bother continuing. */-
3578 if (count == 0)
count == 0Description
TRUEevaluated 458742 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3327171 times by 1 test
Evaluated by:
  • Self test
458742-3327171
3579 break;
executed 458742 times by 1 test: break;
Executed by:
  • Self test
458742
3580-
3581 if (open == '\'') /* '' inside grouping construct */
open == '\''Description
TRUEevaluated 524384 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2802787 times by 1 test
Evaluated by:
  • Self test
524384-2802787
3582 {-
3583 if MBTEST((flags & P_ALLOWESC) && ch == '\\')
(shell_input_line_index > 1)Description
TRUEevaluated 4825 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(flags & 0x0002)Description
TRUEevaluated 15233 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 509151 times by 1 test
Evaluated by:
  • Self test
ch == '\\'Description
TRUEevaluated 4825 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10408 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4825 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-509151
3584 tflags |= LEX_PASSNEXT;
executed 4825 times by 1 test: tflags |= 0x0008;
Executed by:
  • Self test
4825
3585 continue;
executed 524384 times by 1 test: continue;
Executed by:
  • Self test
524384
3586 }-
3587-
3588 if MBTEST(ch == '\\') /* backslashes */
(shell_input_line_index > 1)Description
TRUEevaluated 153494 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(ch == '\\')Description
TRUEevaluated 153494 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2649293 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 153494 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2649293
3589 tflags |= LEX_PASSNEXT;
executed 153494 times by 1 test: tflags |= 0x0008;
Executed by:
  • Self test
153494
3590-
3591 /* Based on which dolstate is currently in (param, op, or word),-
3592 decide what the op is. We're really only concerned if it's % or-
3593 #, so we can turn on a flag that says whether or not we should-
3594 treat single quotes as special when inside a double-quoted-
3595 ${...}. This logic must agree with subst.c:extract_dollar_brace_string-
3596 since they share the same defines. */-
3597 /* FLAG POSIX INTERP 221 */-
3598 if (flags & P_DOLBRACE)
flags & 0x0040Description
TRUEevaluated 178478 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2624309 times by 1 test
Evaluated by:
  • Self test
178478-2624309
3599 {-
3600 /* ${param%[%]word} */-
3601 if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '%' && retind > 1)
(shell_input_line_index > 1)Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 105283 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
ch == '%'Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 102753 times by 1 test
Evaluated by:
  • Self test
retind > 1Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-105283
3602 dolbrace_state = DOLBRACE_QUOTE;
executed 2530 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
2530
3603 /* ${param#[#]word} */-
3604 else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '#' && retind > 1)
(shell_input_line_index > 1)Description
TRUEevaluated 2639 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 102753 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
ch == '#'Description
TRUEevaluated 3150 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 99603 times by 1 test
Evaluated by:
  • Self test
retind > 1Description
TRUEevaluated 2639 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 511 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2639 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-102753
3605 dolbrace_state = DOLBRACE_QUOTE;
executed 2639 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
2639
3606 /* ${param/[/]pat/rep} */-
3607 else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '/' && retind > 1)
(shell_input_line_index > 1)Description
TRUEevaluated 940 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 100114 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
ch == '/'Description
TRUEevaluated 940 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 99174 times by 1 test
Evaluated by:
  • Self test
retind > 1Description
TRUEevaluated 940 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 940 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-100114
3608 dolbrace_state = DOLBRACE_QUOTE2; /* XXX */
executed 940 times by 1 test: dolbrace_state = 0x80;
Executed by:
  • Self test
940
3609 /* ${param^[^]pat} */-
3610 else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '^' && retind > 1)
(shell_input_line_index > 1)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 99174 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
ch == '^'Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 99132 times by 1 test
Evaluated by:
  • Self test
retind > 1Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-99174
3611 dolbrace_state = DOLBRACE_QUOTE;
executed 42 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
42
3612 /* ${param,[,]pat} */-
3613 else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == ',' && retind > 1)
(shell_input_line_index > 1)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 99132 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
ch == ','Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 99088 times by 1 test
Evaluated by:
  • Self test
retind > 1Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-99132
3614 dolbrace_state = DOLBRACE_QUOTE;
executed 44 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
44
3615 else if MBTEST(dolbrace_state == DOLBRACE_PARAM && strchr ("#%^,~:-=?+/", ch) != 0)
(shell_input_line_index > 1)Description
TRUEevaluated 11823 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x01Description
TRUEevaluated 99088 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73195 times by 1 test
Evaluated by:
  • Self test
(__extension__... , ch ))) != 0Description
TRUEevaluated 11823 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 87265 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( ch )Description
TRUEnever evaluated
FALSEevaluated 99088 times by 1 test
Evaluated by:
  • Self test
!__builtin_con...#%^,~:-=?+/" )Description
TRUEnever evaluated
FALSEnever evaluated
( ch ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 11823 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-99088
3616 dolbrace_state = DOLBRACE_OP;
executed 11823 times by 1 test: dolbrace_state = 0x02;
Executed by:
  • Self test
11823
3617 else if MBTEST(dolbrace_state == DOLBRACE_OP && strchr ("#%^,~:-=?+/", ch) == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 11278 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state == 0x02Description
TRUEevaluated 17072 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 143388 times by 1 test
Evaluated by:
  • Self test
(__extension__... , ch ))) == 0Description
TRUEevaluated 11278 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5794 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( ch )Description
TRUEnever evaluated
FALSEevaluated 17072 times by 1 test
Evaluated by:
  • Self test
!__builtin_con...#%^,~:-=?+/" )Description
TRUEnever evaluated
FALSEnever evaluated
( ch ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 11278 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-143388
3618 dolbrace_state = DOLBRACE_WORD;
executed 11278 times by 1 test: dolbrace_state = 0x04;
Executed by:
  • Self test
11278
3619 }
executed 178478 times by 1 test: end of block
Executed by:
  • Self test
178478
3620-
3621 /* The big hammer. Single quotes aren't special in double quotes. The-
3622 problem is that Posix used to say the single quotes are semi-special:-
3623 within a double-quoted ${...} construct "an even number of-
3624 unescaped double-quotes or single-quotes, if any, shall occur." */-
3625 /* This was changed in Austin Group Interp 221 */-
3626 if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
(shell_input_line_index > 1)Description
TRUEevaluated 221 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEevaluated 16672 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2786115 times by 1 test
Evaluated by:
  • Self test
shell_compatibility_level > 41Description
TRUEevaluated 16672 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state != 0x40Description
TRUEevaluated 16624 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
dolbrace_state != 0x80Description
TRUEevaluated 16624 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(flags & 0x0004)Description
TRUEevaluated 6821 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9803 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0040)Description
TRUEevaluated 5161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1660 times by 1 test
Evaluated by:
  • Self test
ch == '\''Description
TRUEevaluated 221 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4940 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 221 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2786115
3627 continue;
executed 221 times by 1 test: continue;
Executed by:
  • Self test
221
3628-
3629 /* Could also check open == '`' if we want to parse grouping constructs-
3630 inside old-style command substitution. */-
3631 if (open != close) /* a grouping construct */
open != closeDescription
TRUEevaluated 590779 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2211787 times by 1 test
Evaluated by:
  • Self test
590779-2211787
3632 {-
3633 if MBTEST(shellquote (ch))
(shell_input_line_index > 1)Description
TRUEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((sh_syntaxtab...h)] & 0x0008))Description
TRUEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 580617 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-580617
3634 {-
3635 /* '', ``, or "" inside $(...) or other grouping construct. */-
3636 push_delimiter (dstack, ch);
executed 263 times by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 3636);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 263 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9899 times by 1 test
Evaluated by:
  • Self test
263-9899
3637 if MBTEST((tflags & LEX_WASDOL) && ch == '\'') /* $'...' inside group */
(shell_input_line_index > 1)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10082 times by 1 test
Evaluated by:
  • Self test
ch == '\''Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10082
3638 nestret = parse_matched_pair (ch, ch, ch, &nestlen, P_ALLOWESC|rflags);
executed 80 times by 1 test: nestret = parse_matched_pair (ch, ch, ch, &nestlen, 0x0002|rflags);
Executed by:
  • Self test
80
3639 else-
3640 nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags);
executed 10082 times by 1 test: nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags);
Executed by:
  • Self test
10082
3641 pop_delimiter (dstack);-
3642 CHECK_NESTRET_ERROR ();
never executed: return &matched_pair_error;
nestret == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
0-10162
3643-
3644 if MBTEST((tflags & LEX_WASDOL) && ch == '\'' && (extended_quote || (rflags & P_DQUOTE) == 0))
(shell_input_line_index > 1)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10082 times by 1 test
Evaluated by:
  • Self test
ch == '\''Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
extended_quoteDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(rflags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10082
3645 {-
3646 /* Translate $'...' here. */-
3647 ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen);-
3648 free (nestret);-
3649-
3650 /* If we're parsing a double-quoted brace expansion and we are-
3651 not in a place where single quotes are treated specially,-
3652 make sure we single-quote the results of the ansi-
3653 expansion because quote removal should remove them later */-
3654 /* FLAG POSIX INTERP 221 */-
3655 if ((shell_compatibility_level > 42) && (rflags & P_DQUOTE) && (dolbrace_state == DOLBRACE_QUOTE2) && (flags & P_DOLBRACE))
(shell_compati...ty_level > 42)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(rflags & 0x0004)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
(dolbrace_state == 0x80)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0040)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
3656 {-
3657 nestret = sh_single_quote (ttrans);-
3658 free (ttrans);-
3659 nestlen = strlen (nestret);-
3660 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
3661 else if ((rflags & P_DQUOTE) == 0)
(rflags & 0x0004) == 0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
25-38
3662 {-
3663 nestret = sh_single_quote (ttrans);-
3664 free (ttrans);-
3665 nestlen = strlen (nestret);-
3666 }
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
3667 else-
3668 {-
3669 nestret = ttrans;-
3670 nestlen = ttranslen;-
3671 }
executed 25 times by 1 test: end of block
Executed by:
  • Self test
25
3672 retind -= 2; /* back up before the $' */-
3673 }
executed 80 times by 1 test: end of block
Executed by:
  • Self test
80
3674 else if MBTEST((tflags & LEX_WASDOL) && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0))
(shell_input_line_index > 1)Description
TRUEnever evaluated
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEnever evaluated
FALSEevaluated 10082 times by 1 test
Evaluated by:
  • Self test
ch == '"'Description
TRUEnever evaluated
FALSEnever evaluated
extended_quoteDescription
TRUEnever evaluated
FALSEnever evaluated
(rflags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-10082
3675 {-
3676 /* Locale expand $"..." here. */-
3677 ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen);-
3678 free (nestret);-
3679-
3680 nestret = sh_mkdoublequoted (ttrans, ttranslen, 0);-
3681 free (ttrans);-
3682 nestlen = ttranslen + 2;-
3683 retind -= 2; /* back up before the $" */-
3684 }
never executed: end of block
0
3685-
3686 APPEND_NESTRET ();
never executed: retsize += (64);
never executed: end of block
executed 10162 times by 1 test: end of block
Executed by:
  • Self test
nestlenDescription
TRUEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-10162
3687 FREE (nestret);
executed 10162 times by 1 test: sh_xfree((nestret), "./parse.y", 3687);
Executed by:
  • Self test
nestretDescription
TRUEevaluated 10162 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10162
3688 }
executed 10162 times by 1 test: end of block
Executed by:
  • Self test
10162
3689 else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
(flags & (0x0020|0x0040))Description
TRUEevaluated 193624 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 386993 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0001)Description
TRUEevaluated 4616 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 189008 times by 1 test
Evaluated by:
  • Self test
ch == '('Description
TRUEevaluated 215 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4401 times by 1 test
Evaluated by:
  • Self test
ch == '{'Description
TRUEevaluated 163 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4238 times by 1 test
Evaluated by:
  • Self test
ch == '['Description
TRUEnever evaluated
FALSEevaluated 4238 times by 1 test
Evaluated by:
  • Self test
0-386993
3690 goto parse_dollar_word;
executed 378 times by 1 test: goto parse_dollar_word;
Executed by:
  • Self test
378
3691#if defined (PROCESS_SUBSTITUTION)-
3692 /* XXX - technically this should only be recognized at the start of-
3693 a word */-
3694 else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_GTLT) && (ch == '(')) /* ) */
(flags & (0x0020|0x0040))Description
TRUEevaluated 193246 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 386993 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x1000)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 193238 times by 1 test
Evaluated by:
  • Self test
(ch == '(')Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
2-386993
3695 goto parse_dollar_word;
executed 2 times by 1 test: goto parse_dollar_word;
Executed by:
  • Self test
2
3696#endif-
3697 }
executed 590399 times by 1 test: end of block
Executed by:
  • Self test
590399
3698 /* Parse an old-style command substitution within double quotes as a-
3699 single word. */-
3700 /* XXX - sh and ksh93 don't do this - XXX */-
3701 else if MBTEST(open == '"' && ch == '`')
(shell_input_line_index > 1)Description
TRUEevaluated 171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
open == '"'Description
TRUEevaluated 1670790 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 540997 times by 1 test
Evaluated by:
  • Self test
ch == '`'Description
TRUEevaluated 171 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1670619 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1670790
3702 {-
3703 nestret = parse_matched_pair (0, '`', '`', &nestlen, rflags);-
3704-
3705 CHECK_NESTRET_ERROR ();
never executed: return &matched_pair_error;
nestret == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 171 times by 1 test
Evaluated by:
  • Self test
0-171
3706 APPEND_NESTRET ();
never executed: retsize += (64);
never executed: end of block
executed 171 times by 1 test: end of block
Executed by:
  • Self test
nestlenDescription
TRUEevaluated 171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 171 times by 1 test
Evaluated by:
  • Self test
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-171
3707-
3708 FREE (nestret);
executed 171 times by 1 test: sh_xfree((nestret), "./parse.y", 3708);
Executed by:
  • Self test
nestretDescription
TRUEevaluated 171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-171
3709 }
executed 171 times by 1 test: end of block
Executed by:
  • Self test
171
3710 else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
(shell_input_line_index > 1)Description
TRUEevaluated 9628 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
open != '`'Description
TRUEevaluated 1670619 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 540997 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0001)Description
TRUEevaluated 230953 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1439666 times by 1 test
Evaluated by:
  • Self test
ch == '('Description
TRUEevaluated 911 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 230042 times by 1 test
Evaluated by:
  • Self test
ch == '{'Description
TRUEevaluated 8717 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 221325 times by 1 test
Evaluated by:
  • Self test
ch == '['Description
TRUEnever evaluated
FALSEevaluated 221325 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 9628 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1670619
3711 /* check for $(), $[], or ${} inside quoted string. */-
3712 {-
3713parse_dollar_word:-
3714 if (open == ch) /* undo previous increment */
open == chDescription
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9847 times by 1 test
Evaluated by:
  • Self test
161-9847
3715 count--;
executed 161 times by 1 test: count--;
Executed by:
  • Self test
161
3716 if (ch == '(') /* ) */
ch == '('Description
TRUEevaluated 1128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8880 times by 1 test
Evaluated by:
  • Self test
1128-8880
3717 nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|P_COMMAND) & ~P_DQUOTE);
executed 1128 times by 1 test: nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|0x0008) & ~0x0004);
Executed by:
  • Self test
1128
3718 else if (ch == '{') /* } */
ch == '{'Description
TRUEevaluated 8880 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8880
3719 nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|P_DOLBRACE|rflags);
executed 8880 times by 1 test: nestret = parse_matched_pair (0, '{', '}', &nestlen, 0x0001|0x0040|rflags);
Executed by:
  • Self test
8880
3720 else if (ch == '[') /* ] */
ch == '['Description
TRUEnever evaluated
FALSEnever evaluated
0
3721 nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
never executed: nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
0
3722-
3723 CHECK_NESTRET_ERROR ();
executed 3 times by 1 test: return &matched_pair_error;
Executed by:
  • Self test
nestret == &matched_pair_errorDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10005 times by 1 test
Evaluated by:
  • Self test
3-10005
3724 APPEND_NESTRET ();
executed 47 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 40 times by 1 test: end of block
Executed by:
  • Self test
executed 10005 times by 1 test: end of block
Executed by:
  • Self test
nestlenDescription
TRUEevaluated 10005 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(retind) + (ne...en) >= retsizeDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9965 times by 1 test
Evaluated by:
  • Self test
(retind) + (ne...en) >= retsizeDescription
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
0-10005
3725-
3726 FREE (nestret);
executed 10005 times by 1 test: sh_xfree((nestret), "./parse.y", 3726);
Executed by:
  • Self test
nestretDescription
TRUEevaluated 10005 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10005
3727 }
executed 10005 times by 1 test: end of block
Executed by:
  • Self test
10005
3728#if defined (PROCESS_SUBSTITUTION)-
3729 if MBTEST((ch == '<' || ch == '>') && (tflags & LEX_GTLT) == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 4565 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '<'Description
TRUEevaluated 2619 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2799944 times by 1 test
Evaluated by:
  • Self test
ch == '>'Description
TRUEevaluated 2000 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2797944 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x1000) == 0Description
TRUEevaluated 4565 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4565 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2799944
3730 tflags |= LEX_GTLT;
executed 4565 times by 1 test: tflags |= 0x1000;
Executed by:
  • Self test
4565
3731 else-
3732 tflags &= ~LEX_GTLT;
executed 2797998 times by 1 test: tflags &= ~0x1000;
Executed by:
  • Self test
2797998
3733#endif-
3734 if MBTEST(ch == '$' && (tflags & LEX_WASDOL) == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 268535 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '$'Description
TRUEevaluated 268542 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2534021 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0001) == 0Description
TRUEevaluated 268535 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 268535 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2534021
3735 tflags |= LEX_WASDOL;
executed 268535 times by 1 test: tflags |= 0x0001;
Executed by:
  • Self test
268535
3736 else-
3737 tflags &= ~LEX_WASDOL;
executed 2534028 times by 1 test: tflags &= ~0x0001;
Executed by:
  • Self test
2534028
3738 }-
3739-
3740 ret[retind] = '\0';-
3741 if (lenp)
lenpDescription
TRUEevaluated 458742 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-458742
3742 *lenp = retind;
executed 458742 times by 1 test: *lenp = retind;
Executed by:
  • Self test
458742
3743/*itrace("parse_matched_pair[%d]: returning %s", line_number, ret);*/-
3744 return ret;
executed 458742 times by 1 test: return ret;
Executed by:
  • Self test
458742
3745}-
3746-
3747#if defined (DEBUG)-
3748static void-
3749dump_tflags (flags)-
3750 int flags;-
3751{-
3752 int f;-
3753-
3754 f = flags;-
3755 fprintf (stderr, "%d -> ", f);-
3756 if (f & LEX_WASDOL)
f & 0x0001Description
TRUEnever evaluated
FALSEnever evaluated
0
3757 {-
3758 f &= ~LEX_WASDOL;-
3759 fprintf (stderr, "LEX_WASDOL%s", f ? "|" : "");-
3760 }
never executed: end of block
0
3761 if (f & LEX_CKCOMMENT)
f & 0x0002Description
TRUEnever evaluated
FALSEnever evaluated
0
3762 {-
3763 f &= ~LEX_CKCOMMENT;-
3764 fprintf (stderr, "LEX_CKCOMMENT%s", f ? "|" : "");-
3765 }
never executed: end of block
0
3766 if (f & LEX_INCOMMENT)
f & 0x0004Description
TRUEnever evaluated
FALSEnever evaluated
0
3767 {-
3768 f &= ~LEX_INCOMMENT;-
3769 fprintf (stderr, "LEX_INCOMMENT%s", f ? "|" : "");-
3770 }
never executed: end of block
0
3771 if (f & LEX_PASSNEXT)
f & 0x0008Description
TRUEnever evaluated
FALSEnever evaluated
0
3772 {-
3773 f &= ~LEX_PASSNEXT;-
3774 fprintf (stderr, "LEX_PASSNEXT%s", f ? "|" : "");-
3775 }
never executed: end of block
0
3776 if (f & LEX_RESWDOK)
f & 0x0010Description
TRUEnever evaluated
FALSEnever evaluated
0
3777 {-
3778 f &= ~LEX_RESWDOK;-
3779 fprintf (stderr, "LEX_RESWDOK%s", f ? "|" : "");-
3780 }
never executed: end of block
0
3781 if (f & LEX_CKCASE)
f & 0x0020Description
TRUEnever evaluated
FALSEnever evaluated
0
3782 {-
3783 f &= ~LEX_CKCASE;-
3784 fprintf (stderr, "LEX_CKCASE%s", f ? "|" : "");-
3785 }
never executed: end of block
0
3786 if (f & LEX_INCASE)
f & 0x0040Description
TRUEnever evaluated
FALSEnever evaluated
0
3787 {-
3788 f &= ~LEX_INCASE;-
3789 fprintf (stderr, "LEX_INCASE%s", f ? "|" : "");-
3790 }
never executed: end of block
0
3791 if (f & LEX_INHEREDOC)
f & 0x0080Description
TRUEnever evaluated
FALSEnever evaluated
0
3792 {-
3793 f &= ~LEX_INHEREDOC;-
3794 fprintf (stderr, "LEX_INHEREDOC%s", f ? "|" : "");-
3795 }
never executed: end of block
0
3796 if (f & LEX_HEREDELIM)
f & 0x0100Description
TRUEnever evaluated
FALSEnever evaluated
0
3797 {-
3798 f &= ~LEX_HEREDELIM;-
3799 fprintf (stderr, "LEX_HEREDELIM%s", f ? "|" : "");-
3800 }
never executed: end of block
0
3801 if (f & LEX_STRIPDOC)
f & 0x0200Description
TRUEnever evaluated
FALSEnever evaluated
0
3802 {-
3803 f &= ~LEX_STRIPDOC;-
3804 fprintf (stderr, "LEX_WASDOL%s", f ? "|" : "");-
3805 }
never executed: end of block
0
3806 if (f & LEX_QUOTEDDOC)
f & 0x0400Description
TRUEnever evaluated
FALSEnever evaluated
0
3807 {-
3808 f &= ~LEX_QUOTEDDOC;-
3809 fprintf (stderr, "LEX_QUOTEDDOC%s", f ? "|" : "");-
3810 }
never executed: end of block
0
3811 if (f & LEX_INWORD)
f & 0x0800Description
TRUEnever evaluated
FALSEnever evaluated
0
3812 {-
3813 f &= ~LEX_INWORD;-
3814 fprintf (stderr, "LEX_INWORD%s", f ? "|" : "");-
3815 }
never executed: end of block
0
3816-
3817 fprintf (stderr, "\n");-
3818 fflush (stderr);-
3819}
never executed: end of block
0
3820#endif-
3821-
3822/* Parse a $(...) command substitution. This is messier than I'd like, and-
3823 reproduces a lot more of the token-reading code than I'd like. */-
3824static char *-
3825parse_comsub (qc, open, close, lenp, flags)-
3826 int qc; /* `"' if this construct is within double quotes */-
3827 int open, close;-
3828 int *lenp, flags;-
3829{-
3830 int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind;-
3831 int nestlen, ttranslen, start_lineno;-
3832 char *ret, *nestret, *ttrans, *heredelim;-
3833 int retind, retsize, rflags, hdlen;-
3834-
3835 /* Posix interp 217 says arithmetic expressions have precedence, so-
3836 assume $(( introduces arithmetic expansion and parse accordingly. */-
3837 peekc = shell_getc (0);-
3838 shell_ungetc (peekc);-
3839 if (peekc == '(')
peekc == '('Description
TRUEevaluated 1330 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
1330-23171
3840 return (parse_matched_pair (qc, open, close, lenp, 0));
executed 1330 times by 1 test: return (parse_matched_pair (qc, open, close, lenp, 0));
Executed by:
  • Self test
1330
3841-
3842/*itrace("parse_comsub: qc = `%c' open = %c close = %c", qc, open, close);*/-
3843 count = 1;-
3844 tflags = LEX_RESWDOK;-
3845-
3846 if ((flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0)
(flags & 0x0008)Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
qc != '\''Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
qc != '"'Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(flags & 0x0004) == 0Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-23171
3847 tflags |= LEX_CKCASE;
executed 23171 times by 1 test: tflags |= 0x0020;
Executed by:
  • Self test
23171
3848 if ((tflags & LEX_CKCASE) && (interactive == 0 || interactive_comments))
(tflags & 0x0020)Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
interactive == 0Description
TRUEevaluated 23171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
interactive_commentsDescription
TRUEnever evaluated
FALSEnever evaluated
0-23171
3849 tflags |= LEX_CKCOMMENT;
executed 23171 times by 1 test: tflags |= 0x0002;
Executed by:
  • Self test
23171
3850-
3851 /* RFLAGS is the set of flags we want to pass to recursive calls. */-
3852 rflags = (flags & P_DQUOTE);-
3853-
3854 ret = (char *)xmalloc (retsize = 64);-
3855 retind = 0;-
3856-
3857 start_lineno = line_number;-
3858 lex_rwlen = lex_wlen = 0;-
3859-
3860 heredelim = 0;-
3861 lex_firstind = -1;-
3862-
3863 while (count)
countDescription
TRUEevaluated 287113 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-287113
3864 {-
3865comsub_readchar:-
3866 ch = shell_getc (qc != '\'' && (tflags & (LEX_INCOMMENT|LEX_PASSNEXT|LEX_QUOTEDDOC)) == 0);-
3867-
3868 if (ch == EOF)
ch == (-1)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 287109 times by 1 test
Evaluated by:
  • Self test
4-287109
3869 {-
3870eof_error:-
3871 free (ret);-
3872 FREE (heredelim);
executed 2 times by 1 test: sh_xfree((heredelim), "./parse.y", 3872);
Executed by:
  • Self test
heredelimDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2
3873 parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), close);-
3874 EOF_Reached = 1; /* XXX */-
3875 return (&matched_pair_error);
executed 4 times by 1 test: return (&matched_pair_error);
Executed by:
  • Self test
4
3876 }-
3877-
3878 /* If we hit the end of a line and are reading the contents of a here-
3879 document, and it's not the same line that the document starts on,-
3880 check for this line being the here doc delimiter. Otherwise, if-
3881 we're in a here document, mark the next character as the beginning-
3882 of a line. */-
3883 if (ch == '\n')
ch == '\n'Description
TRUEevaluated 2751 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 284358 times by 1 test
Evaluated by:
  • Self test
2751-284358
3884 {-
3885 if ((tflags & LEX_HEREDELIM) && heredelim)
(tflags & 0x0100)Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2421 times by 1 test
Evaluated by:
  • Self test
heredelimDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 289 times by 1 test
Evaluated by:
  • Self test
41-2421
3886 {-
3887 tflags &= ~LEX_HEREDELIM;-
3888 tflags |= LEX_INHEREDOC;-
3889 lex_firstind = retind + 1;-
3890 }
executed 41 times by 1 test: end of block
Executed by:
  • Self test
41
3891 else if (tflags & LEX_INHEREDOC)
tflags & 0x0080Description
TRUEevaluated 684 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2026 times by 1 test
Evaluated by:
  • Self test
684-2026
3892 {-
3893 int tind;-
3894 tind = lex_firstind;-
3895 while ((tflags & LEX_STRIPDOC) && ret[tind] == '\t')
(tflags & 0x0200)Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 620 times by 1 test
Evaluated by:
  • Self test
ret[tind] == '\t'Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
32-620
3896 tind++;
executed 32 times by 1 test: tind++;
Executed by:
  • Self test
32
3897 if (retind-tind == hdlen && STREQN (ret + tind, heredelim, hdlen))
never executed: __result = (((const unsigned char *) (const char *) ( ret + tind ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( heredelim ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(hdlen == 0)Description
TRUEnever evaluated
FALSEevaluated 331 times by 1 test
Evaluated by:
  • Self test
retind-tind == hdlenDescription
TRUEevaluated 331 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 353 times by 1 test
Evaluated by:
  • Self test
((hdlen == 0) ...len ))) == 0))Description
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
(ret + tind)[0...(heredelim)[0]Description
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
(__extension__...hdlen ))) == 0Description
TRUEevaluated 317 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_constant_p ( hdlen )Description
TRUEnever evaluated
FALSEevaluated 317 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...( ret + tind )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( ret +..._t) ( hdlen ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons... ( heredelim )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( hered..._t) ( hdlen ))Description
TRUEnever evaluated
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-353
3898 {-
3899 tflags &= ~(LEX_STRIPDOC|LEX_INHEREDOC|LEX_QUOTEDDOC);-
3900/*itrace("parse_comsub:%d: found here doc end `%s'", line_number, ret + tind);*/-
3901 free (heredelim);-
3902 heredelim = 0;-
3903 lex_firstind = -1;-
3904 }
executed 317 times by 1 test: end of block
Executed by:
  • Self test
317
3905 else-
3906 lex_firstind = retind + 1;
executed 367 times by 1 test: lex_firstind = retind + 1;
Executed by:
  • Self test
367
3907 }-
3908 }
executed 2751 times by 1 test: end of block
Executed by:
  • Self test
2751
3909-
3910 /* Possible reprompting. */-
3911 if (ch == '\n' && SHOULD_PROMPT ())
ch == '\n'Description
TRUEevaluated 2751 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 284358 times by 1 test
Evaluated by:
  • Self test
interactiveDescription
TRUEnever evaluated
FALSEevaluated 2751 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-284358
3912 prompt_again ();
never executed: prompt_again ();
0
3913-
3914 /* XXX -- possibly allow here doc to be delimited by ending right-
3915 paren. */-
3916 if ((tflags & LEX_INHEREDOC) && ch == close && count == 1)
(tflags & 0x0080)Description
TRUEevaluated 4652 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 282457 times by 1 test
Evaluated by:
  • Self test
ch == closeDescription
TRUEevaluated 167 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4485 times by 1 test
Evaluated by:
  • Self test
count == 1Description
TRUEevaluated 167 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-282457
3917 {-
3918 int tind;-
3919/*itrace("parse_comsub:%d: in here doc, ch == close, retind - firstind = %d hdlen = %d retind = %d", line_number, retind-lex_firstind, hdlen, retind);*/-
3920 tind = lex_firstind;-
3921 while ((tflags & LEX_STRIPDOC) && ret[tind] == '\t')
(tflags & 0x0200)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 135 times by 1 test
Evaluated by:
  • Self test
ret[tind] == '\t'Description
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
0-135
3922 tind++;
never executed: tind++;
0
3923 if (retind-tind == hdlen && STREQN (ret + tind, heredelim, hdlen))
never executed: __result = (((const unsigned char *) (const char *) ( ret + tind ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( heredelim ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(hdlen == 0)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
retind-tind == hdlenDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
((hdlen == 0) ...len ))) == 0))Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(ret + tind)[0...(heredelim)[0]Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(__extension__...hdlen ))) == 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_constant_p ( hdlen )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...( ret + tind )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( ret +..._t) ( hdlen ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons... ( heredelim )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( hered..._t) ( hdlen ))Description
TRUEnever evaluated
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-156
3924 {-
3925 tflags &= ~(LEX_STRIPDOC|LEX_INHEREDOC|LEX_QUOTEDDOC);-
3926/*itrace("parse_comsub:%d: found here doc end `%*s'", line_number, hdlen, ret + tind);*/-
3927 free (heredelim);-
3928 heredelim = 0;-
3929 lex_firstind = -1;-
3930 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
3931 }
executed 167 times by 1 test: end of block
Executed by:
  • Self test
167
3932-
3933 /* Don't bother counting parens or doing anything else if in a comment or-
3934 here document (not exactly right for here-docs -- if we want to allow-
3935 recursive calls to parse_comsub to have their own here documents,-
3936 change the LEX_INHEREDOC to LEX_QUOTEDDOC here and uncomment the next-
3937 clause below. Note that to make this work completely, we need to make-
3938 additional changes to allow xparse_dolparen to work right when the-
3939 command substitution is parsed, because read_secondary_line doesn't know-
3940 to recursively parse through command substitutions embedded in here--
3941 documents */-
3942 if (tflags & (LEX_INCOMMENT|LEX_INHEREDOC))
tflags & (0x0004|0x0080)Description
TRUEevaluated 7562 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 279547 times by 1 test
Evaluated by:
  • Self test
7562-279547
3943 {-
3944 /* Add this character. */-
3945 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 4 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 4 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7558 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-7558
3946 ret[retind++] = ch;-
3947-
3948 if ((tflags & LEX_INCOMMENT) && ch == '\n')
(tflags & 0x0004)Description
TRUEevaluated 2921 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4641 times by 1 test
Evaluated by:
  • Self test
ch == '\n'Description
TRUEevaluated 233 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2688 times by 1 test
Evaluated by:
  • Self test
233-4641
3949 {-
3950/*itrace("parse_comsub:%d: lex_incomment -> 0 ch = `%c'", line_number, ch);*/-
3951 tflags &= ~LEX_INCOMMENT;-
3952 }
executed 233 times by 1 test: end of block
Executed by:
  • Self test
233
3953-
3954 continue;
executed 7562 times by 1 test: continue;
Executed by:
  • Self test
7562
3955 }-
3956#if 0-
3957 /* If we're going to recursively parse a command substitution inside a-
3958 here-document, make sure we call parse_comsub recursively below. See-
3959 above for additional caveats. */-
3960 if ((tflags & LEX_INHEREDOC) && ((tflags & LEX_WASDOL) == 0 || ch != '(')) /*)*/-
3961 {-
3962 /* Add this character. */-
3963 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);-
3964 ret[retind++] = ch;-
3965 if MBTEST(ch == '$')-
3966 tflags |= LEX_WASDOL;-
3967 else-
3968 tflags &= ~LEX_WASDOL;-
3969 }-
3970#endif-
3971-
3972 if (tflags & LEX_PASSNEXT) /* last char was backslash */
tflags & 0x0008Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 279289 times by 1 test
Evaluated by:
  • Self test
258-279289
3973 {-
3974/*itrace("parse_comsub:%d: lex_passnext -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/-
3975 tflags &= ~LEX_PASSNEXT;-
3976 if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */
qc != '\''Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '\n'Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • Self test
0-258
3977 {-
3978 if (retind > 0)
retind > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3979 retind--; /* swallow previously-added backslash */
never executed: retind--;
0
3980 continue;
never executed: continue;
0
3981 }-
3982-
3983 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
executed 2 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 2 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (2) >= retsizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 256 times by 1 test
Evaluated by:
  • Self test
(retind) + (2) >= retsizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-256
3984 if MBTEST(ch == CTLESC)
(shell_input_line_index > 1)Description
TRUEnever evaluated
FALSEnever evaluated
(ch == '\001')Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-258
3985 ret[retind++] = CTLESC;
never executed: ret[retind++] = '\001';
0
3986 ret[retind++] = ch;-
3987 continue;
executed 258 times by 1 test: continue;
Executed by:
  • Self test
258
3988 }-
3989-
3990 /* If this is a shell break character, we are not in a word. If not,-
3991 we either start or continue a word. */-
3992 if MBTEST(shellbreak (ch))
(shell_input_line_index > 1)Description
TRUEevaluated 77297 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1773 times by 1 test
Evaluated by:
  • Self test
((sh_syntaxtab...h)] & 0x0002))Description
TRUEevaluated 79070 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 200219 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 79070 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-200219
3993 {-
3994 tflags &= ~LEX_INWORD;-
3995/*itrace("parse_comsub:%d: lex_inword -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/-
3996 }
executed 79070 times by 1 test: end of block
Executed by:
  • Self test
79070
3997 else-
3998 {-
3999 if (tflags & LEX_INWORD)
tflags & 0x0800Description
TRUEevaluated 147445 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 52774 times by 1 test
Evaluated by:
  • Self test
52774-147445
4000 {-
4001 lex_wlen++;-
4002/*itrace("parse_comsub:%d: lex_inword == 1 ch = `%c' lex_wlen = %d (%d)", line_number, ch, lex_wlen, __LINE__);*/-
4003 }
executed 147445 times by 1 test: end of block
Executed by:
  • Self test
147445
4004 else-
4005 {-
4006/*itrace("parse_comsub:%d: lex_inword -> 1 ch = `%c' (%d)", line_number, ch, __LINE__);*/-
4007 tflags |= LEX_INWORD;-
4008 lex_wlen = 0;-
4009 if (tflags & LEX_RESWDOK)
tflags & 0x0010Description
TRUEevaluated 30313 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22461 times by 1 test
Evaluated by:
  • Self test
22461-30313
4010 lex_rwlen = 0;
executed 30313 times by 1 test: lex_rwlen = 0;
Executed by:
  • Self test
30313
4011 }
executed 52774 times by 1 test: end of block
Executed by:
  • Self test
52774
4012 }-
4013-
4014 /* Skip whitespace */-
4015 if MBTEST(shellblank (ch) && (tflags & LEX_HEREDELIM) == 0 && lex_rwlen == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 17138 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 990 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...ch)] & 0x2000)Description
TRUEevaluated 49025 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 230264 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0100) == 0Description
TRUEevaluated 48842 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 183 times by 1 test
Evaluated by:
  • Self test
lex_rwlen == 0Description
TRUEevaluated 18128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30714 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 18128 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-230264
4016 {-
4017 /* Add this character. */-
4018 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 94 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 94 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18034 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
94-18034
4019 ret[retind++] = ch;-
4020 continue;
executed 18128 times by 1 test: continue;
Executed by:
  • Self test
18128
4021 }-
4022-
4023 /* Either we are looking for the start of the here-doc delimiter-
4024 (lex_firstind == -1) or we are reading one (lex_firstind >= 0).-
4025 If this character is a shell break character and we are reading-
4026 the delimiter, save it and note that we are now reading a here-
4027 document. If we've found the start of the delimiter, note it by-
4028 setting lex_firstind. Backslashes can quote shell metacharacters-
4029 in here-doc delimiters. */-
4030 if (tflags & LEX_HEREDELIM)
tflags & 0x0100Description
TRUEevaluated 1328 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 259833 times by 1 test
Evaluated by:
  • Self test
1328-259833
4031 {-
4032 if (lex_firstind == -1 && shellbreak (ch) == 0)
lex_firstind == -1Description
TRUEevaluated 490 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 838 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...& 0x0002) == 0Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 142 times by 1 test
Evaluated by:
  • Self test
142-838
4033 lex_firstind = retind;
executed 348 times by 1 test: lex_firstind = retind;
Executed by:
  • Self test
348
4034#if 0-
4035 else if (heredelim && (tflags & LEX_PASSNEXT) == 0 && ch == '\n')-
4036 {-
4037 tflags |= LEX_INHEREDOC;-
4038 tflags &= ~LEX_HEREDELIM;-
4039 lex_firstind = retind + 1;-
4040 }-
4041#endif-
4042 else if (lex_firstind >= 0 && (tflags & LEX_PASSNEXT) == 0 && shellbreak (ch))
lex_firstind >= 0Description
TRUEevaluated 838 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 142 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0008) == 0Description
TRUEevaluated 838 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(sh_syntaxtab[...ch)] & 0x0002)Description
TRUEevaluated 339 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 499 times by 1 test
Evaluated by:
  • Self test
0-838
4043 {-
4044 if (heredelim == 0)
heredelim == 0Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-330
4045 {-
4046 nestret = substring (ret, lex_firstind, retind);-
4047 heredelim = string_quote_removal (nestret, 0);-
4048 hdlen = STRLEN(heredelim);
(heredelim)[1]Description
TRUEevaluated 298 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
(heredelim)[2]Description
TRUEevaluated 298 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(heredelim)Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(heredelim)[0]Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-330
4049/*itrace("parse_comsub:%d: found here doc delimiter `%s' (%d)", line_number, heredelim, hdlen);*/-
4050 if (STREQ (heredelim, nestret) == 0)
never executed: __result = (((const unsigned char *) (const char *) ( heredelim ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( nestret ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((heredelim)[0... }) == 0) == 0Description
TRUEevaluated 182 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 148 times by 1 test
Evaluated by:
  • Self test
(heredelim)[0] == (nestret)[0]Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 182 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 148 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-182
4051 tflags |= LEX_QUOTEDDOC;
executed 182 times by 1 test: tflags |= 0x0400;
Executed by:
  • Self test
182
4052 free (nestret);-
4053 }
executed 330 times by 1 test: end of block
Executed by:
  • Self test
330
4054 if (ch == '\n')
ch == '\n'Description
TRUEevaluated 289 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 50 times by 1 test
Evaluated by:
  • Self test
50-289
4055 {-
4056 tflags |= LEX_INHEREDOC;-
4057 tflags &= ~LEX_HEREDELIM;-
4058 lex_firstind = retind + 1;-
4059 }
executed 289 times by 1 test: end of block
Executed by:
  • Self test
289
4060 else-
4061 lex_firstind = -1;
executed 50 times by 1 test: lex_firstind = -1;
Executed by:
  • Self test
50
4062 }-
4063 }
executed 1328 times by 1 test: end of block
Executed by:
  • Self test
1328
4064-
4065 /* Meta-characters that can introduce a reserved word. Not perfect yet. */-
4066 if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && (shellmeta(ch) || ch == '\n'))
(shell_input_line_index > 1)Description
TRUEevaluated 24221 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0010) == 0Description
TRUEevaluated 122476 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 138685 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0020)Description
TRUEevaluated 122476 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0004) == 0Description
TRUEevaluated 122476 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(sh_syntaxtab[...ch)] & 0x0001)Description
TRUEevaluated 23559 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 98917 times by 1 test
Evaluated by:
  • Self test
ch == '\n'Description
TRUEevaluated 729 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 98188 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 24288 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-138685
4067 {-
4068 /* Add this character. */-
4069 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 12 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 12 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24276 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-24276
4070 ret[retind++] = ch;-
4071 peekc = shell_getc (1);-
4072 if (ch == peekc && (ch == '&' || ch == '|' || ch == ';')) /* two-character tokens */
ch == peekcDescription
TRUEevaluated 287 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24001 times by 1 test
Evaluated by:
  • Self test
ch == '&'Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274 times by 1 test
Evaluated by:
  • Self test
ch == '|'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 260 times by 1 test
Evaluated by:
  • Self test
ch == ';'Description
TRUEevaluated 241 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
13-24001
4073 {-
4074 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 268 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-268
4075 ret[retind++] = peekc;-
4076/*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/-
4077 tflags |= LEX_RESWDOK;-
4078 lex_rwlen = 0;-
4079 continue;
executed 268 times by 1 test: continue;
Executed by:
  • Self test
268
4080 }-
4081 else if (ch == '\n' || COMSUB_META(ch))
ch == '\n'Description
TRUEevaluated 729 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23291 times by 1 test
Evaluated by:
  • Self test
(ch) == ';'Description
TRUEevaluated 2746 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20545 times by 1 test
Evaluated by:
  • Self test
(ch) == '&'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20531 times by 1 test
Evaluated by:
  • Self test
(ch) == '|'Description
TRUEevaluated 287 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20244 times by 1 test
Evaluated by:
  • Self test
14-23291
4082 {-
4083 shell_ungetc (peekc);-
4084/*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/-
4085 tflags |= LEX_RESWDOK;-
4086 lex_rwlen = 0;-
4087 continue;
executed 3776 times by 1 test: continue;
Executed by:
  • Self test
3776
4088 }-
4089 else if (ch == EOF)
ch == (-1)Description
TRUEnever evaluated
FALSEevaluated 20244 times by 1 test
Evaluated by:
  • Self test
0-20244
4090 goto eof_error;
never executed: goto eof_error;
0
4091 else-
4092 {-
4093 /* `unget' the character we just added and fall through */-
4094 retind--;-
4095 shell_ungetc (peekc);-
4096 }
executed 20244 times by 1 test: end of block
Executed by:
  • Self test
20244
4097 }-
4098-
4099 /* If we can read a reserved word, try to read one. */-
4100 if (tflags & LEX_RESWDOK)
tflags & 0x0010Description
TRUEevaluated 138685 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 118432 times by 1 test
Evaluated by:
  • Self test
118432-138685
4101 {-
4102 if MBTEST(islower ((unsigned char)ch))
(shell_input_line_index > 1)Description
TRUEevaluated 105083 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 351 times by 1 test
Evaluated by:
  • Self test
( ((*__ctype_b...t) _ISlower) )Description
TRUEevaluated 105434 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33251 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 105434 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-105434
4103 {-
4104 /* Add this character. */-
4105 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 14 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 14 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 105420 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
14-105420
4106 ret[retind++] = ch;-
4107 lex_rwlen++;-
4108 continue;
executed 105434 times by 1 test: continue;
Executed by:
  • Self test
105434
4109 }-
4110 else if MBTEST(lex_rwlen == 4 && shellbreak (ch))
(shell_input_line_index > 1)Description
TRUEevaluated 21253 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
lex_rwlen == 4Description
TRUEevaluated 21424 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11827 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...ch)] & 0x0002)Description
TRUEevaluated 21253 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 171 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 21253 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-21424
4111 {-
4112 if (STREQN (ret + retind - 4, "case", 4))
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "case" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20705 times by 1 test
Evaluated by:
  • Self test
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 21253 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("case")[0]Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20705 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_constant_p ( 4 )Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 548 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "case" )Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "case...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 548 times by 1 test
Evaluated by:
  • Self test
__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-21253
4113 {-
4114 tflags |= LEX_INCASE;-
4115 tflags &= ~LEX_RESWDOK;-
4116/*itrace("parse_comsub:%d: found `case', lex_incase -> 1 lex_reswdok -> 0", line_number);*/-
4117 }
executed 548 times by 1 test: end of block
Executed by:
  • Self test
548
4118 else if (STREQN (ret + retind - 4, "esac", 4))
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "esac" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20157 times by 1 test
Evaluated by:
  • Self test
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20705 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("esac")[0]Description
TRUEevaluated 18272 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2433 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEevaluated 548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 18272 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 18272 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "esac" )Description
TRUEevaluated 18272 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "esac...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 18272 times by 1 test
Evaluated by:
  • Self test
__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-20705
4119 {-
4120 tflags &= ~LEX_INCASE;-
4121/*itrace("parse_comsub:%d: found `esac', lex_incase -> 0 lex_reswdok -> 1", line_number);*/-
4122 tflags |= LEX_RESWDOK;-
4123 lex_rwlen = 0;-
4124 }
executed 548 times by 1 test: end of block
Executed by:
  • Self test
548
4125 else if (STREQN (ret + retind - 4, "done", 4) ||
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "done" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20157 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20096 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("done")[0]Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20085 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "done" )Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "done...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
__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-20157
4126 STREQN (ret + retind - 4, "then", 4) ||
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "then" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20096 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("then")[0]Description
TRUEevaluated 2315 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17781 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 2315 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 2315 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "then" )Description
TRUEevaluated 2315 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "then...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 2315 times by 1 test
Evaluated by:
  • Self test
__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-20096
4127 STREQN (ret + retind - 4, "else", 4) ||
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "else" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("else")[0]Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2371 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "else" )Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "else...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
__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-20095
4128 STREQN (ret + retind - 4, "elif", 4) ||
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "elif" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("elif")[0]Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2371 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "elif" )Description
TRUEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "elif...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 17724 times by 1 test
Evaluated by:
  • Self test
__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-20095
4129 STREQN (ret + retind - 4, "time", 4))
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 4 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "time" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEnever evaluated
FALSEevaluated 20095 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...== ("time")[0]Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17781 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 4 ))) == 0Description
TRUEnever evaluated
FALSEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 4 )Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 4 )Description
TRUEnever evaluated
FALSEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( "time" )Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "time...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
__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-20095
4130 {-
4131 /* these are four-character reserved words that can be-
4132 followed by a reserved word; anything else turns off-
4133 the reserved-word-ok flag */-
4134/*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 1", line_number, ret+retind-4);*/-
4135 tflags |= LEX_RESWDOK;-
4136 lex_rwlen = 0;-
4137 }
executed 62 times by 1 test: end of block
Executed by:
  • Self test
62
4138 else if (shellmeta (ch) == 0)
(sh_syntaxtab[...& 0x0001) == 0Description
TRUEevaluated 17797 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2298 times by 1 test
Evaluated by:
  • Self test
2298-17797
4139 {-
4140 tflags &= ~LEX_RESWDOK;-
4141/*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 0", line_number, ret+retind-4);*/-
4142 }
executed 17797 times by 1 test: end of block
Executed by:
  • Self test
17797
4143 else /* can't be in a reserved word any more */-
4144 lex_rwlen = 0;
executed 2298 times by 1 test: lex_rwlen = 0;
Executed by:
  • Self test
2298
4145 }-
4146 else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0)))
(shell_input_line_index > 1)Description
TRUEevaluated 152 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0002)Description
TRUEevaluated 11998 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '#'Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11832 times by 1 test
Evaluated by:
  • Self test
lex_rwlen == 0Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0800)Description
TRUEnever evaluated
FALSEnever evaluated
lex_wlen == 0Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11998
4147 ; /* don't modify LEX_RESWDOK if we're starting a comment */
executed 166 times by 1 test: ;
Executed by:
  • Self test
166
4148 /* Allow `do' followed by space, tab, or newline to preserve the-
4149 RESWDOK flag, but reset the reserved word length counter so we-
4150 can read another one. */-
4151 else if MBTEST(((tflags & LEX_INCASE) == 0) &&
never executed: __result = (((const unsigned char *) (const char *) ( ret + retind - 2 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "do" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(2 == 0)Description
TRUEnever evaluated
FALSEevaluated 166 times by 1 test
Evaluated by:
  • Self test
(shell_input_line_index > 1)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((tflags & 0x0040) == 0)Description
TRUEevaluated 11178 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 654 times by 1 test
Evaluated by:
  • Self test
((*__ctype_b_l...int) _ISblank)Description
TRUEevaluated 3921 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7257 times by 1 test
Evaluated by:
  • Self test
ch == '\n'Description
TRUEevaluated 810 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6447 times by 1 test
Evaluated by:
  • Self test
lex_rwlen == 2Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4565 times by 1 test
Evaluated by:
  • Self test
((2 == 0) ? (1..., 2 ))) == 0))Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 105 times by 1 test
Evaluated by:
  • Self test
(ret + retind ...] == ("do")[0]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 105 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , 2 ))) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_constant_p ( 2 )Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...+ retind - 2 )Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
strlen ( ret +...size_t) ( 2 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( "do" )Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "do" ...size_t) ( 2 ))Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
__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
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11178
4152 (isblank((unsigned char)ch) || ch == '\n') &&-
4153 lex_rwlen == 2 &&-
4154 STREQN (ret + retind - 2, "do", 2))-
4155 {-
4156/*itrace("parse_comsub:%d: lex_incase == 0 found `%c', found \"do\"", line_number, ch);*/-
4157 lex_rwlen = 0;-
4158 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
4159 else if MBTEST((tflags & LEX_INCASE) && ch != '\n')
(shell_input_line_index > 1)Description
TRUEevaluated 276 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0040)Description
TRUEevaluated 654 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11117 times by 1 test
Evaluated by:
  • Self test
ch != '\n'Description
TRUEevaluated 284 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 370 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 284 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11117
4160 /* If we can read a reserved word and we're in case, we're at the-
4161 point where we can read a new pattern list or an esac. We-
4162 handle the esac case above. If we read a newline, we want to-
4163 leave LEX_RESWDOK alone. If we read anything else, we want to-
4164 turn off LEX_RESWDOK, since we're going to read a pattern list. */-
4165 {-
4166 tflags &= ~LEX_RESWDOK;-
4167/*itrace("parse_comsub:%d: lex_incase == 1 found `%c', lex_reswordok -> 0", line_number, ch);*/-
4168 }
executed 284 times by 1 test: end of block
Executed by:
  • Self test
284
4169 else if MBTEST(shellbreak (ch) == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 4905 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((sh_syntaxtab... 0x0002) == 0)Description
TRUEevaluated 4905 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6582 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4905 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6582
4170 {-
4171 tflags &= ~LEX_RESWDOK;-
4172/*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/-
4173 }
executed 4905 times by 1 test: end of block
Executed by:
  • Self test
4905
4174#if 0-
4175 /* If we find a space or tab but have read something and it's not-
4176 `do', turn off the reserved-word-ok flag */-
4177 else if MBTEST(isblank ((unsigned char)ch) && lex_rwlen > 0)-
4178 {-
4179 tflags &= ~LEX_RESWDOK;-
4180/*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/-
4181 }-
4182#endif-
4183 }
executed 33251 times by 1 test: end of block
Executed by:
  • Self test
33251
4184-
4185 /* Might be the start of a here-doc delimiter */-
4186 if MBTEST((tflags & LEX_INCOMMENT) == 0 && (tflags & LEX_CKCASE) && ch == '<')
(shell_input_line_index > 1)Description
TRUEevaluated 378 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0004) == 0Description
TRUEevaluated 151683 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0020)Description
TRUEevaluated 151683 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '<'Description
TRUEevaluated 378 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 151305 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 378 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-151683
4187 {-
4188 /* Add this character. */-
4189 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 378 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-378
4190 ret[retind++] = ch;-
4191 peekc = shell_getc (1);-
4192 if (peekc == EOF)
peekc == (-1)Description
TRUEnever evaluated
FALSEevaluated 378 times by 1 test
Evaluated by:
  • Self test
0-378
4193 goto eof_error;
never executed: goto eof_error;
0
4194 if (peekc == ch)
peekc == chDescription
TRUEevaluated 332 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 46 times by 1 test
Evaluated by:
  • Self test
46-332
4195 {-
4196 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 332 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-332
4197 ret[retind++] = peekc;-
4198 peekc = shell_getc (1);-
4199 if (peekc == EOF)
peekc == (-1)Description
TRUEnever evaluated
FALSEevaluated 332 times by 1 test
Evaluated by:
  • Self test
0-332
4200 goto eof_error;
never executed: goto eof_error;
0
4201 if (peekc == '-')
peekc == '-'Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 300 times by 1 test
Evaluated by:
  • Self test
32-300
4202 {-
4203 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-32
4204 ret[retind++] = peekc;-
4205 tflags |= LEX_STRIPDOC;-
4206 }
executed 32 times by 1 test: end of block
Executed by:
  • Self test
32
4207 else-
4208 shell_ungetc (peekc);
executed 300 times by 1 test: shell_ungetc (peekc);
Executed by:
  • Self test
300
4209 if (peekc != '<')
peekc != '<'Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-330
4210 {-
4211 tflags |= LEX_HEREDELIM;-
4212 lex_firstind = -1;-
4213 }
executed 330 times by 1 test: end of block
Executed by:
  • Self test
330
4214 continue;
executed 332 times by 1 test: continue;
Executed by:
  • Self test
332
4215 }-
4216 else-
4217 {-
4218 shell_ungetc (peekc); /* not a here-doc, start over */-
4219 continue;
executed 46 times by 1 test: continue;
Executed by:
  • Self test
46
4220 }-
4221 }-
4222 else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (((tflags & LEX_RESWDOK) && lex_rwlen == 0) || ((tflags & LEX_INWORD) && lex_wlen == 0)))
(shell_input_line_index > 1)Description
TRUEevaluated 219 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0002)Description
TRUEevaluated 151305 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0004) == 0Description
TRUEevaluated 151305 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '#'Description
TRUEevaluated 275 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 151030 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0010)Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109 times by 1 test
Evaluated by:
  • Self test
lex_rwlen == 0Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0800)Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
lex_wlen == 0Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 233 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-151305
4223 {-
4224/*itrace("parse_comsub:%d: lex_incomment -> 1 (%d)", line_number, __LINE__);*/-
4225 tflags |= LEX_INCOMMENT;-
4226 }
executed 233 times by 1 test: end of block
Executed by:
  • Self test
233
4227-
4228 if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */
(shell_input_line_index > 1)Description
TRUEnever evaluated
FALSEnever evaluated
ch == '\001'Description
TRUEnever evaluated
FALSEevaluated 151305 times by 1 test
Evaluated by:
  • Self test
ch == '\177'Description
TRUEnever evaluated
FALSEevaluated 151305 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-151305
4229 {-
4230 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
never executed: retsize += (64);
never executed: end of block
(retind) + (2) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
(retind) + (2) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4231 ret[retind++] = CTLESC;-
4232 ret[retind++] = ch;-
4233 continue;
never executed: continue;
0
4234 }-
4235#if 0-
4236 else if MBTEST((tflags & LEX_INCASE) && ch == close && close == ')')-
4237 tflags &= ~LEX_INCASE; /* XXX */-
4238#endif-
4239 else if MBTEST(ch == close && (tflags & LEX_INCASE) == 0) /* ending delimiter */
(shell_input_line_index > 1)Description
TRUEevaluated 22505 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 671 times by 1 test
Evaluated by:
  • Self test
ch == closeDescription
TRUEevaluated 23746 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 127559 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0040) == 0Description
TRUEevaluated 23176 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 570 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 23176 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-127559
4240 {-
4241 count--;-
4242/*itrace("parse_comsub:%d: found close: count = %d", line_number, count);*/-
4243 }
executed 23176 times by 1 test: end of block
Executed by:
  • Self test
23176
4244 else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && (tflags & LEX_INCASE) == 0 && ch == open) /* nested begin */
(shell_input_line_index > 1)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((flags & 0x0001) == 0)Description
TRUEevaluated 128129 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0040) == 0Description
TRUEevaluated 116449 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11680 times by 1 test
Evaluated by:
  • Self test
ch == openDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116435 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-128129
4245 {-
4246 count++;-
4247/*itrace("parse_comsub:%d: found open: count = %d", line_number, count);*/-
4248 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
4249-
4250 /* Add this character. */-
4251 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
executed 70 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 70 times by 1 test: end of block
Executed by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 151235 times by 1 test
Evaluated by:
  • Self test
(retind) + (1) >= retsizeDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
70-151235
4252 ret[retind++] = ch;-
4253-
4254 /* If we just read the ending character, don't bother continuing. */-
4255 if (count == 0)
count == 0Description
TRUEevaluated 23167 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 128138 times by 1 test
Evaluated by:
  • Self test
23167-128138
4256 break;
executed 23167 times by 1 test: break;
Executed by:
  • Self test
23167
4257-
4258 if MBTEST(ch == '\\') /* backslashes */
(shell_input_line_index > 1)Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(ch == '\\')Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 127880 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-127880
4259 tflags |= LEX_PASSNEXT;
executed 258 times by 1 test: tflags |= 0x0008;
Executed by:
  • Self test
258
4260-
4261 if MBTEST(shellquote (ch))
(shell_input_line_index > 1)Description
TRUEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((sh_syntaxtab...h)] & 0x0008))Description
TRUEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 126457 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-126457
4262 {-
4263 /* '', ``, or "" inside $(...). */-
4264 push_delimiter (dstack, ch);
executed 1 time by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 4264);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1680 times by 1 test
Evaluated by:
  • Self test
1-1680
4265 if MBTEST((tflags & LEX_WASDOL) && ch == '\'') /* $'...' inside group */
(shell_input_line_index > 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1659 times by 1 test
Evaluated by:
  • Self test
ch == '\''Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1659
4266 nestret = parse_matched_pair (ch, ch, ch, &nestlen, P_ALLOWESC|rflags);
executed 22 times by 1 test: nestret = parse_matched_pair (ch, ch, ch, &nestlen, 0x0002|rflags);
Executed by:
  • Self test
22
4267 else-
4268 nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags);
executed 1659 times by 1 test: nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags);
Executed by:
  • Self test
1659
4269 pop_delimiter (dstack);-
4270 CHECK_NESTRET_ERROR ();
never executed: return &matched_pair_error;
nestret == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
0-1681
4271-
4272 if MBTEST((tflags & LEX_WASDOL) && ch == '\'' && (extended_quote || (rflags & P_DQUOTE) == 0))
(shell_input_line_index > 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1659 times by 1 test
Evaluated by:
  • Self test
ch == '\''Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
extended_quoteDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(rflags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1659
4273 {-
4274 /* Translate $'...' here. */-
4275 ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen);-
4276 free (nestret);-
4277-
4278 if ((rflags & P_DQUOTE) == 0)
(rflags & 0x0004) == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-22
4279 {-
4280 nestret = sh_single_quote (ttrans);-
4281 free (ttrans);-
4282 nestlen = strlen (nestret);-
4283 }
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
4284 else-
4285 {-
4286 nestret = ttrans;-
4287 nestlen = ttranslen;-
4288 }
never executed: end of block
0
4289 retind -= 2; /* back up before the $' */-
4290 }
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
4291 else if MBTEST((tflags & LEX_WASDOL) && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0))
(shell_input_line_index > 1)Description
TRUEnever evaluated
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEnever evaluated
FALSEevaluated 1659 times by 1 test
Evaluated by:
  • Self test
ch == '"'Description
TRUEnever evaluated
FALSEnever evaluated
extended_quoteDescription
TRUEnever evaluated
FALSEnever evaluated
(rflags & 0x0004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-1659
4292 {-
4293 /* Locale expand $"..." here. */-
4294 ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen);-
4295 free (nestret);-
4296-
4297 nestret = sh_mkdoublequoted (ttrans, ttranslen, 0);-
4298 free (ttrans);-
4299 nestlen = ttranslen + 2;-
4300 retind -= 2; /* back up before the $" */-
4301 }
never executed: end of block
0
4302-
4303 APPEND_NESTRET ();
executed 107 times by 1 test: retsize += (64);
Executed by:
  • Self test
executed 88 times by 1 test: end of block
Executed by:
  • Self test
executed 1681 times by 1 test: end of block
Executed by:
  • Self test
nestlenDescription
TRUEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(retind) + (ne...en) >= retsizeDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1593 times by 1 test
Evaluated by:
  • Self test
(retind) + (ne...en) >= retsizeDescription
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 88 times by 1 test
Evaluated by:
  • Self test
0-1681
4304 FREE (nestret);
executed 1681 times by 1 test: sh_xfree((nestret), "./parse.y", 4304);
Executed by:
  • Self test
nestretDescription
TRUEevaluated 1681 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1681
4305 }
executed 1681 times by 1 test: end of block
Executed by:
  • Self test
1681
4306 else if MBTEST((tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
(shell_input_line_index > 1)Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tflags & 0x0001)Description
TRUEevaluated 482 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 125975 times by 1 test
Evaluated by:
  • Self test
ch == '('Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 447 times by 1 test
Evaluated by:
  • Self test
ch == '{'Description
TRUEevaluated 176 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 271 times by 1 test
Evaluated by:
  • Self test
ch == '['Description
TRUEnever evaluated
FALSEevaluated 271 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-125975
4307 /* check for $(), $[], or ${} inside command substitution. */-
4308 {-
4309 if ((tflags & LEX_INCASE) == 0 && open == ch) /* undo previous increment */
(tflags & 0x0040) == 0Description
TRUEevaluated 181 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
open == chDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 176 times by 1 test
Evaluated by:
  • Self test
5-181
4310 count--;
executed 5 times by 1 test: count--;
Executed by:
  • Self test
5
4311 if (ch == '(') /* ) */
ch == '('Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 176 times by 1 test
Evaluated by:
  • Self test
35-176
4312 nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|P_COMMAND) & ~P_DQUOTE);
executed 35 times by 1 test: nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|0x0008) & ~0x0004);
Executed by:
  • Self test
35
4313 else if (ch == '{') /* } */
ch == '{'Description
TRUEevaluated 176 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-176
4314 nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|P_DOLBRACE|rflags);
executed 176 times by 1 test: nestret = parse_matched_pair (0, '{', '}', &nestlen, 0x0001|0x0040|rflags);
Executed by:
  • Self test
176
4315 else if (ch == '[') /* ] */
ch == '['Description
TRUEnever evaluated
FALSEnever evaluated
0
4316 nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
never executed: nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
0
4317-
4318 CHECK_NESTRET_ERROR ();
never executed: return &matched_pair_error;
nestret == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 211 times by 1 test
Evaluated by:
  • Self test
0-211
4319 APPEND_NESTRET ();
never executed: retsize += (64);
never executed: end of block
executed 211 times by 1 test: end of block
Executed by:
  • Self test
nestlenDescription
TRUEevaluated 211 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEevaluated 211 times by 1 test
Evaluated by:
  • Self test
(retind) + (ne...en) >= retsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-211
4320-
4321 FREE (nestret);
executed 211 times by 1 test: sh_xfree((nestret), "./parse.y", 4321);
Executed by:
  • Self test
nestretDescription
TRUEevaluated 211 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-211
4322 }
executed 211 times by 1 test: end of block
Executed by:
  • Self test
211
4323 if MBTEST(ch == '$' && (tflags & LEX_WASDOL) == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 504 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ch == '$'Description
TRUEevaluated 506 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 127632 times by 1 test
Evaluated by:
  • Self test
(tflags & 0x0001) == 0Description
TRUEevaluated 504 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 504 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-127632
4324 tflags |= LEX_WASDOL;
executed 504 times by 1 test: tflags |= 0x0001;
Executed by:
  • Self test
504
4325 else-
4326 tflags &= ~LEX_WASDOL;
executed 127634 times by 1 test: tflags &= ~0x0001;
Executed by:
  • Self test
127634
4327 }-
4328-
4329 FREE (heredelim);
never executed: sh_xfree((heredelim), "./parse.y", 4329);
heredelimDescription
TRUEnever evaluated
FALSEevaluated 23167 times by 1 test
Evaluated by:
  • Self test
0-23167
4330 ret[retind] = '\0';-
4331 if (lenp)
lenpDescription
TRUEevaluated 23167 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-23167
4332 *lenp = retind;
executed 23167 times by 1 test: *lenp = retind;
Executed by:
  • Self test
23167
4333/*itrace("parse_comsub:%d: returning `%s'", line_number, ret);*/-
4334 return ret;
executed 23167 times by 1 test: return ret;
Executed by:
  • Self test
23167
4335}-
4336-
4337/* Recursively call the parser to parse a $(...) command substitution. */-
4338char *-
4339xparse_dolparen (base, string, indp, flags)-
4340 char *base;-
4341 char *string;-
4342 int *indp;-
4343 int flags;-
4344{-
4345 sh_parser_state_t ps;-
4346 sh_input_line_state_t ls;-
4347 int orig_ind, nc, sflags, orig_eof_token;-
4348 char *ret, *ep, *ostring;-
4349#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
4350 STRING_SAVER *saved_pushed_strings;-
4351#endif-
4352-
4353/*debug_parser(1);*/-
4354 orig_ind = *indp;-
4355 ostring = string;-
4356-
4357 if (*string == 0)
*string == 0Description
TRUEnever evaluated
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-705307
4358 {-
4359 if (flags & SX_NOALLOC)
flags & 0x0001Description
TRUEnever evaluated
FALSEnever evaluated
0
4360 return (char *)NULL;
never executed: return (char *) ((void *)0) ;
0
4361-
4362 ret = xmalloc (1);-
4363 ret[0] = '\0';-
4364 return ret;
never executed: return ret;
0
4365 }-
4366-
4367/*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/-
4368 sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE;-
4369 if (flags & SX_NOLONGJMP)
flags & 0x0040Description
TRUEevaluated 69 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705238 times by 1 test
Evaluated by:
  • Self test
69-705238
4370 sflags |= SEVAL_NOLONGJMP;
executed 69 times by 1 test: sflags |= 0x040;
Executed by:
  • Self test
69
4371 save_parser_state (&ps);-
4372 save_input_line_state (&ls);-
4373 orig_eof_token = shell_eof_token;-
4374#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
4375 saved_pushed_strings = pushed_string_list; /* separate parsing context */-
4376 pushed_string_list = (STRING_SAVER *)NULL;-
4377#endif-
4378-
4379 /*(*/-
4380 parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/-
4381 shell_eof_token = ')';-
4382-
4383 /* Should we save and restore the bison/yacc lookahead token (yychar) here?-
4384 Or only if it's not YYEMPTY? */-
4385-
4386 nc = parse_string (string, "command substitution", sflags, &ep);-
4387-
4388 if (current_token == shell_eof_token)
current_token ...hell_eof_tokenDescription
TRUEevaluated 704328 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 979 times by 1 test
Evaluated by:
  • Self test
979-704328
4389 yyclearin; /* might want to clear lookahead token unconditionally */
executed 704328 times by 1 test: (yychar = (-2));
Executed by:
  • Self test
704328
4390-
4391 shell_eof_token = orig_eof_token;-
4392 restore_parser_state (&ps);-
4393 reset_parser ();-
4394 /* reset_parser clears shell_input_line and associated variables */-
4395 restore_input_line_state (&ls);-
4396-
4397#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)-
4398 pushed_string_list = saved_pushed_strings;-
4399#endif-
4400-
4401 token_to_read = 0;-
4402-
4403 /* If parse_string returns < 0, we need to jump to top level with the-
4404 negative of the return value. We abandon the rest of this input line-
4405 first */-
4406 if (nc < 0)
nc < 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705300 times by 1 test
Evaluated by:
  • Self test
7-705300
4407 {-
4408 clear_shell_input_line (); /* XXX */-
4409 jump_to_top_level (-nc); /* XXX */-
4410 }
never executed: end of block
0
4411-
4412 /* Need to find how many characters parse_and_execute consumed, update-
4413 *indp, if flags != 0, copy the portion of the string parsed into RET-
4414 and return it. If flags & 1 (SX_NOALLOC) we can return NULL. */-
4415-
4416 /*(*/-
4417 if (ep[-1] != ')')
ep[-1] != ')'Description
TRUEnever evaluated
FALSEevaluated 705300 times by 1 test
Evaluated by:
  • Self test
0-705300
4418 {-
4419#if DEBUG-
4420 if (ep[-1] != '\n')
ep[-1] != '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
4421 itrace("xparse_dolparen:%d: ep[-1] != RPAREN (%d), ep = `%s'", line_number, ep[-1], ep);
never executed: itrace("xparse_dolparen:%d: ep[-1] != RPAREN (%d), ep = `%s'", line_number, ep[-1], ep);
0
4422#endif-
4423 while (ep > ostring && ep[-1] == '\n') ep--;
never executed: ep--;
ep > ostringDescription
TRUEnever evaluated
FALSEnever evaluated
ep[-1] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
4424 }
never executed: end of block
0
4425-
4426 nc = ep - ostring;-
4427 *indp = ep - base - 1;-
4428-
4429 /*(*/-
4430#if DEBUG-
4431 if (base[*indp] != ')')
base[*indp] != ')'Description
TRUEnever evaluated
FALSEevaluated 705300 times by 1 test
Evaluated by:
  • Self test
0-705300
4432 itrace("xparse_dolparen:%d: base[%d] != RPAREN (%d), base = `%s'", line_number, *indp, base[*indp], base);
never executed: itrace("xparse_dolparen:%d: base[%d] != RPAREN (%d), base = `%s'", line_number, *indp, base[*indp], base);
0
4433 if (*indp < orig_ind)
*indp < orig_indDescription
TRUEnever evaluated
FALSEevaluated 705300 times by 1 test
Evaluated by:
  • Self test
0-705300
4434 itrace("xparse_dolparen:%d: *indp (%d) < orig_ind (%d), orig_string = `%s'", line_number, *indp, orig_ind, ostring);
never executed: itrace("xparse_dolparen:%d: *indp (%d) < orig_ind (%d), orig_string = `%s'", line_number, *indp, orig_ind, ostring);
0
4435#endif-
4436-
4437 if (flags & SX_NOALLOC)
flags & 0x0001Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 705088 times by 1 test
Evaluated by:
  • Self test
212-705088
4438 return (char *)NULL;
executed 212 times by 1 test: return (char *) ((void *)0) ;
Executed by:
  • Self test
212
4439-
4440 if (nc == 0)
nc == 0Description
TRUEnever evaluated
FALSEevaluated 705088 times by 1 test
Evaluated by:
  • Self test
0-705088
4441 {-
4442 ret = xmalloc (1);-
4443 ret[0] = '\0';-
4444 }
never executed: end of block
0
4445 else-
4446 ret = substring (ostring, 0, nc - 1);
executed 705088 times by 1 test: ret = substring (ostring, 0, nc - 1);
Executed by:
  • Self test
705088
4447-
4448 return ret;
executed 705088 times by 1 test: return ret;
Executed by:
  • Self test
705088
4449}-
4450-
4451#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)-
4452/* Parse a double-paren construct. It can be either an arithmetic-
4453 command, an arithmetic `for' command, or a nested subshell. Returns-
4454 the parsed token, -1 on error, or -2 if we didn't do anything and-
4455 should just go on. */-
4456static int-
4457parse_dparen (c)-
4458 int c;-
4459{-
4460 int cmdtyp, sline;-
4461 char *wval;-
4462 WORD_DESC *wd;-
4463-
4464#if defined (ARITH_FOR_COMMAND)-
4465 if (last_read_token == FOR)
last_read_token == 265Description
TRUEevaluated 2641 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47097 times by 1 test
Evaluated by:
  • Self test
2641-47097
4466 {-
4467 arith_for_lineno = line_number;-
4468 cmdtyp = parse_arith_cmd (&wval, 0);-
4469 if (cmdtyp == 1)
cmdtyp == 1Description
TRUEevaluated 2641 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2641
4470 {-
4471 wd = alloc_word_desc ();-
4472 wd->word = wval;-
4473 yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);-
4474 return (ARITH_FOR_EXPRS);
executed 2641 times by 1 test: return (286);
Executed by:
  • Self test
2641
4475 }-
4476 else-
4477 return -1; /* ERROR */
never executed: return -1;
0
4478 }-
4479#endif-
4480-
4481#if defined (DPAREN_ARITHMETIC)-
4482 if (reserved_word_acceptable (last_read_token))
reserved_word_...st_read_token)Description
TRUEevaluated 47097 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-47097
4483 {-
4484 sline = line_number;-
4485-
4486 cmdtyp = parse_arith_cmd (&wval, 0);-
4487 if (cmdtyp == 1) /* arithmetic command */
cmdtyp == 1Description
TRUEevaluated 47077 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
20-47077
4488 {-
4489 wd = alloc_word_desc ();-
4490 wd->word = wval;-
4491 wd->flags = W_QUOTED|W_NOSPLIT|W_NOGLOB|W_DQUOTE;-
4492 yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);-
4493 return (ARITH_CMD);
executed 47077 times by 1 test: return (285);
Executed by:
  • Self test
47077
4494 }-
4495 else if (cmdtyp == 0) /* nested subshell */
cmdtyp == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-20
4496 {-
4497 push_string (wval, 0, (alias_t *)NULL);-
4498 pushed_string_list->flags = PSH_DPAREN;-
4499 if ((parser_state & PST_CASEPAT) == 0)
(parser_state & 0x000001) == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-20
4500 parser_state |= PST_SUBSHELL;
executed 20 times by 1 test: parser_state |= 0x000020;
Executed by:
  • Self test
20
4501 return (c);
executed 20 times by 1 test: return (c);
Executed by:
  • Self test
20
4502 }-
4503 else /* ERROR */-
4504 return -1;
never executed: return -1;
0
4505 }-
4506#endif-
4507-
4508 return -2; /* XXX */
never executed: return -2;
0
4509}-
4510-
4511/* We've seen a `(('. Look for the matching `))'. If we get it, return 1.-
4512 If not, assume it's a nested subshell for backwards compatibility and-
4513 return 0. In any case, put the characters we've consumed into a locally--
4514 allocated buffer and make *ep point to that buffer. Return -1 on an-
4515 error, for example EOF. */-
4516static int-
4517parse_arith_cmd (ep, adddq)-
4518 char **ep;-
4519 int adddq;-
4520{-
4521 int exp_lineno, rval, c;-
4522 char *ttok, *tokstr;-
4523 int ttoklen;-
4524-
4525 exp_lineno = line_number;-
4526 ttok = parse_matched_pair (0, '(', ')', &ttoklen, 0);-
4527 rval = 1;-
4528 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 49738 times by 1 test
Evaluated by:
  • Self test
0-49738
4529 return -1;
never executed: return -1;
0
4530 /* Check that the next character is the closing right paren. If-
4531 not, this is a syntax error. ( */-
4532 c = shell_getc (0);-
4533 if MBTEST(c != ')')
(shell_input_line_index > 1)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(c != ')')Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49718 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-49718
4534 rval = 0;
executed 20 times by 1 test: rval = 0;
Executed by:
  • Self test
20
4535-
4536 tokstr = (char *)xmalloc (ttoklen + 4);-
4537-
4538 /* if ADDDQ != 0 then (( ... )) -> "..." */-
4539 if (rval == 1 && adddq) /* arith cmd, add double quotes */
rval == 1Description
TRUEevaluated 49718 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
adddqDescription
TRUEnever evaluated
FALSEevaluated 49718 times by 1 test
Evaluated by:
  • Self test
0-49718
4540 {-
4541 tokstr[0] = '"';-
4542 strncpy (tokstr + 1, ttok, ttoklen - 1);-
4543 tokstr[ttoklen] = '"';-
4544 tokstr[ttoklen+1] = '\0';-
4545 }
never executed: end of block
0
4546 else if (rval == 1) /* arith cmd, don't add double quotes */
rval == 1Description
TRUEevaluated 49718 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
20-49718
4547 {-
4548 strncpy (tokstr, ttok, ttoklen - 1);-
4549 tokstr[ttoklen-1] = '\0';-
4550 }
executed 49718 times by 1 test: end of block
Executed by:
  • Self test
49718
4551 else /* nested subshell */-
4552 {-
4553 tokstr[0] = '(';-
4554 strncpy (tokstr + 1, ttok, ttoklen - 1);-
4555 tokstr[ttoklen] = ')';-
4556 tokstr[ttoklen+1] = c;-
4557 tokstr[ttoklen+2] = '\0';-
4558 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test
20
4559-
4560 *ep = tokstr;-
4561 FREE (ttok);
executed 49738 times by 1 test: sh_xfree((ttok), "./parse.y", 4561);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 49738 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-49738
4562 return rval;
executed 49738 times by 1 test: return rval;
Executed by:
  • Self test
49738
4563}-
4564#endif /* DPAREN_ARITHMETIC || ARITH_FOR_COMMAND */-
4565-
4566#if defined (COND_COMMAND)-
4567static void-
4568cond_error ()-
4569{-
4570 char *etext;-
4571-
4572 if (EOF_Reached && cond_token != COND_ERROR) /* [[ */
EOF_ReachedDescription
TRUEnever evaluated
FALSEnever evaluated
cond_token != 275Description
TRUEnever evaluated
FALSEnever evaluated
0
4573 parser_error (cond_lineno, _("unexpected EOF while looking for `]]'"));
never executed: parser_error (cond_lineno, dcgettext (((void *)0), "unexpected EOF while looking for `]]'" , 5) );
0
4574 else if (cond_token != COND_ERROR)
cond_token != 275Description
TRUEnever evaluated
FALSEnever evaluated
0
4575 {-
4576 if (etext = error_token_from_token (cond_token))
etext = error_...n (cond_token)Description
TRUEnever evaluated
FALSEnever evaluated
0
4577 {-
4578 parser_error (cond_lineno, _("syntax error in conditional expression: unexpected token `%s'"), etext);-
4579 free (etext);-
4580 }
never executed: end of block
0
4581 else-
4582 parser_error (cond_lineno, _("syntax error in conditional expression"));
never executed: parser_error (cond_lineno, dcgettext (((void *)0), "syntax error in conditional expression" , 5) );
0
4583 }-
4584}
never executed: end of block
0
4585-
4586static COND_COM *-
4587cond_expr ()-
4588{-
4589 return (cond_or ());
executed 583 times by 1 test: return (cond_or ());
Executed by:
  • Self test
583
4590}-
4591-
4592static COND_COM *-
4593cond_or ()-
4594{-
4595 COND_COM *l, *r;-
4596-
4597 l = cond_and ();-
4598 if (cond_token == OR_OR)
cond_token == 289Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 583 times by 1 test
Evaluated by:
  • Self test
27-583
4599 {-
4600 r = cond_or ();-
4601 l = make_cond_node (COND_OR, (WORD_DESC *)NULL, l, r);-
4602 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
4603 return l;
executed 610 times by 1 test: return l;
Executed by:
  • Self test
610
4604}-
4605-
4606static COND_COM *-
4607cond_and ()-
4608{-
4609 COND_COM *l, *r;-
4610-
4611 l = cond_term ();-
4612 if (cond_token == AND_AND)
cond_token == 288Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 610 times by 1 test
Evaluated by:
  • Self test
71-610
4613 {-
4614 r = cond_and ();-
4615 l = make_cond_node (COND_AND, (WORD_DESC *)NULL, l, r);-
4616 }
executed 71 times by 1 test: end of block
Executed by:
  • Self test
71
4617 return l;
executed 681 times by 1 test: return l;
Executed by:
  • Self test
681
4618}-
4619-
4620static int-
4621cond_skip_newlines ()-
4622{-
4623 while ((cond_token = read_token (READ)) == '\n')
(cond_token = ...n (0)) == '\n'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1309 times by 1 test
Evaluated by:
  • Self test
20-1309
4624 {-
4625 if (SHOULD_PROMPT ())
interactiveDescription
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-20
4626 prompt_again ();
never executed: prompt_again ();
0
4627 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test
20
4628 return (cond_token);
executed 1309 times by 1 test: return (cond_token);
Executed by:
  • Self test
1309
4629}-
4630-
4631#define COND_RETURN_ERROR() \-
4632 do { cond_token = COND_ERROR; return ((COND_COM *)NULL); } while (0)-
4633-
4634static COND_COM *-
4635cond_term ()-
4636{-
4637 WORD_DESC *op;-
4638 COND_COM *term, *tleft, *tright;-
4639 int tok, lineno;-
4640 char *etext;-
4641-
4642 /* Read a token. It can be a left paren, a `!', a unary operator, or a-
4643 word that should be the first argument of a binary operator. Start by-
4644 skipping newlines, since this is a compound command. */-
4645 tok = cond_skip_newlines ();-
4646 lineno = line_number;-
4647 if (tok == COND_END)
tok == 274Description
TRUEnever evaluated
FALSEevaluated 693 times by 1 test
Evaluated by:
  • Self test
0-693
4648 {-
4649 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4650 }
never executed: end of block
0
4651 else if (tok == '(')
tok == '('Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 684 times by 1 test
Evaluated by:
  • Self test
9-684
4652 {-
4653 term = cond_expr ();-
4654 if (cond_token != ')')
cond_token != ')'Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
4655 {-
4656 if (term)
termDescription
TRUEnever evaluated
FALSEnever evaluated
0
4657 dispose_cond_node (term); /* ( */
never executed: dispose_cond_node (term);
0
4658 if (etext = error_token_from_token (cond_token))
etext = error_...n (cond_token)Description
TRUEnever evaluated
FALSEnever evaluated
0
4659 {-
4660 parser_error (lineno, _("unexpected token `%s', expected `)'"), etext);-
4661 free (etext);-
4662 }
never executed: end of block
0
4663 else-
4664 parser_error (lineno, _("expected `)'"));
never executed: parser_error (lineno, dcgettext (((void *)0), "expected `)'" , 5) );
0
4665 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4666 }-
4667 term = make_cond_node (COND_EXPR, (WORD_DESC *)NULL, term, (COND_COM *)NULL);-
4668 (void)cond_skip_newlines ();-
4669 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test
9
4670 else if (tok == BANG || (tok == WORD && (yylval.word->word[0] == '!' && yylval.word->word[1] == '\0')))
tok == 277Description
TRUEnever evaluated
FALSEevaluated 684 times by 1 test
Evaluated by:
  • Self test
tok == 281Description
TRUEevaluated 684 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
yylval.word->word[0] == '!'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 672 times by 1 test
Evaluated by:
  • Self test
yylval.word->word[1] == '\0'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-684
4671 {-
4672 if (tok == WORD)
tok == 281Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
4673 dispose_word (yylval.word); /* not needed */
executed 12 times by 1 test: dispose_word (yylval.word);
Executed by:
  • Self test
12
4674 term = cond_term ();-
4675 if (term)
termDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
4676 term->flags |= CMD_INVERT_RETURN;
executed 12 times by 1 test: term->flags |= 0x04;
Executed by:
  • Self test
12
4677 }
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
4678 else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word))
tok == 281Description
TRUEevaluated 672 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
yylval.word->word[0] == '-'Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 540 times by 1 test
Evaluated by:
  • Self test
yylval.word->word[1]Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
yylval.word->word[2] == 0Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
test_unop (yylval.word->word)Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-672
4679 {-
4680 op = yylval.word;-
4681 tok = read_token (READ);-
4682 if (tok == WORD)
tok == 281Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-132
4683 {-
4684 tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);-
4685 term = make_cond_node (COND_UNARY, op, tleft, (COND_COM *)NULL);-
4686 }
executed 132 times by 1 test: end of block
Executed by:
  • Self test
132
4687 else-
4688 {-
4689 dispose_word (op);-
4690 if (etext = error_token_from_token (tok))
etext = error_...om_token (tok)Description
TRUEnever evaluated
FALSEnever evaluated
0
4691 {-
4692 parser_error (line_number, _("unexpected argument `%s' to conditional unary operator"), etext);-
4693 free (etext);-
4694 }
never executed: end of block
0
4695 else-
4696 parser_error (line_number, _("unexpected argument to conditional unary operator"));
never executed: parser_error (line_number, dcgettext (((void *)0), "unexpected argument to conditional unary operator" , 5) );
0
4697 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4698 }-
4699-
4700 (void)cond_skip_newlines ();-
4701 }
executed 132 times by 1 test: end of block
Executed by:
  • Self test
132
4702 else if (tok == WORD) /* left argument to binary operator */
tok == 281Description
TRUEevaluated 540 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-540
4703 {-
4704 /* lhs */-
4705 tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);-
4706-
4707 /* binop */-
4708 tok = read_token (READ);-
4709 if (tok == WORD && test_binop (yylval.word->word))
tok == 281Description
TRUEevaluated 473 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
test_binop (yylval.word->word)Description
TRUEevaluated 382 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test
67-473
4710 {-
4711 op = yylval.word;-
4712 if (op->word[0] == '=' && (op->word[1] == '\0' || (op->word[1] == '=' && op->word[2] == '\0')))
op->word[0] == '='Description
TRUEevaluated 242 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
op->word[1] == '\0'Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 192 times by 1 test
Evaluated by:
  • Self test
op->word[1] == '='Description
TRUEevaluated 192 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
op->word[2] == '\0'Description
TRUEevaluated 192 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-242
4713 parser_state |= PST_EXTPAT;
executed 242 times by 1 test: parser_state |= 0x001000;
Executed by:
  • Self test
242
4714 else if (op->word[0] == '!' && op->word[1] == '=' && op->word[2] == '\0')
op->word[0] == '!'Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
op->word[1] == '='Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
op->word[2] == '\0'Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-94
4715 parser_state |= PST_EXTPAT;
executed 46 times by 1 test: parser_state |= 0x001000;
Executed by:
  • Self test
46
4716 }
executed 382 times by 1 test: end of block
Executed by:
  • Self test
382
4717#if defined (COND_REGEXP)-
4718 else if (tok == WORD && STREQ (yylval.word->word, "=~"))
never executed: __result = (((const unsigned char *) (const char *) ( yylval.word->word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "=~" ))[3] - __s2[3]);
executed 91 times by 1 test: end of block
Executed by:
  • Self test
executed 91 times by 1 test: end of block
Executed by:
  • Self test
tok == 281Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
(yylval.word->...] == ("=~")[0]Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEevaluated 91 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
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s2_len > 1Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-91
4719 {-
4720 op = yylval.word;-
4721 parser_state |= PST_REGEXP;-
4722 }
executed 91 times by 1 test: end of block
Executed by:
  • Self test
91
4723#endif-
4724 else if (tok == '<' || tok == '>')
tok == '<'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
tok == '>'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
1-66
4725 op = make_word_from_token (tok); /* ( */
executed 2 times by 1 test: op = make_word_from_token (tok);
Executed by:
  • Self test
2
4726 /* There should be a check before blindly accepting the `)' that we have-
4727 seen the opening `('. */-
4728 else if (tok == COND_END || tok == AND_AND || tok == OR_OR || tok == ')')
tok == 274Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
tok == 288Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
tok == 289Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
tok == ')'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-49
4729 {-
4730 /* Special case. [[ x ]] is equivalent to [[ -n x ]], just like-
4731 the test command. Similarly for [[ x && expr ]] or-
4732 [[ x || expr ]] or [[ (x) ]]. */-
4733 op = make_word ("-n");-
4734 term = make_cond_node (COND_UNARY, op, tleft, (COND_COM *)NULL);-
4735 cond_token = tok;-
4736 return (term);
executed 65 times by 1 test: return (term);
Executed by:
  • Self test
65
4737 }-
4738 else-
4739 {-
4740 if (etext = error_token_from_token (tok))
etext = error_...om_token (tok)Description
TRUEnever evaluated
FALSEnever evaluated
0
4741 {-
4742 parser_error (line_number, _("unexpected token `%s', conditional binary operator expected"), etext);-
4743 free (etext);-
4744 }
never executed: end of block
0
4745 else-
4746 parser_error (line_number, _("conditional binary operator expected"));
never executed: parser_error (line_number, dcgettext (((void *)0), "conditional binary operator expected" , 5) );
0
4747 dispose_cond_node (tleft);-
4748 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4749 }-
4750-
4751 /* rhs */-
4752 if (parser_state & PST_EXTPAT)
parser_state & 0x001000Description
TRUEevaluated 288 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 187 times by 1 test
Evaluated by:
  • Self test
187-288
4753 extended_glob = 1;
executed 288 times by 1 test: extended_glob = 1;
Executed by:
  • Self test
288
4754 tok = read_token (READ);-
4755 if (parser_state & PST_EXTPAT)
parser_state & 0x001000Description
TRUEevaluated 288 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 187 times by 1 test
Evaluated by:
  • Self test
187-288
4756 extended_glob = global_extglob;
executed 288 times by 1 test: extended_glob = global_extglob;
Executed by:
  • Self test
288
4757 parser_state &= ~(PST_REGEXP|PST_EXTPAT);-
4758-
4759 if (tok == WORD)
tok == 281Description
TRUEevaluated 475 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-475
4760 {-
4761 tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);-
4762 term = make_cond_node (COND_BINARY, op, tleft, tright);-
4763 }
executed 475 times by 1 test: end of block
Executed by:
  • Self test
475
4764 else-
4765 {-
4766 if (etext = error_token_from_token (tok))
etext = error_...om_token (tok)Description
TRUEnever evaluated
FALSEnever evaluated
0
4767 {-
4768 parser_error (line_number, _("unexpected argument `%s' to conditional binary operator"), etext);-
4769 free (etext);-
4770 }
never executed: end of block
0
4771 else-
4772 parser_error (line_number, _("unexpected argument to conditional binary operator"));
never executed: parser_error (line_number, dcgettext (((void *)0), "unexpected argument to conditional binary operator" , 5) );
0
4773 dispose_cond_node (tleft);-
4774 dispose_word (op);-
4775 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4776 }-
4777-
4778 (void)cond_skip_newlines ();-
4779 }
executed 475 times by 1 test: end of block
Executed by:
  • Self test
475
4780 else-
4781 {-
4782 if (tok < 256)
tok < 256Description
TRUEnever evaluated
FALSEnever evaluated
0
4783 parser_error (line_number, _("unexpected token `%c' in conditional command"), tok);
never executed: parser_error (line_number, dcgettext (((void *)0), "unexpected token `%c' in conditional command" , 5) , tok);
0
4784 else if (etext = error_token_from_token (tok))
etext = error_...om_token (tok)Description
TRUEnever evaluated
FALSEnever evaluated
0
4785 {-
4786 parser_error (line_number, _("unexpected token `%s' in conditional command"), etext);-
4787 free (etext);-
4788 }
never executed: end of block
0
4789 else-
4790 parser_error (line_number, _("unexpected token %d in conditional command"), tok);
never executed: parser_error (line_number, dcgettext (((void *)0), "unexpected token %d in conditional command" , 5) , tok);
0
4791 COND_RETURN_ERROR ();
never executed: return ((COND_COM *) ((void *)0) );
0
4792 }-
4793 return (term);
executed 628 times by 1 test: return (term);
Executed by:
  • Self test
628
4794} -
4795-
4796/* This is kind of bogus -- we slip a mini recursive-descent parser in-
4797 here to handle the conditional statement syntax. */-
4798static COMMAND *-
4799parse_cond_command ()-
4800{-
4801 COND_COM *cexp;-
4802-
4803 global_extglob = extended_glob;-
4804 cexp = cond_expr ();-
4805 return (make_cond_command (cexp));
executed 574 times by 1 test: return (make_cond_command (cexp));
Executed by:
  • Self test
574
4806}-
4807#endif-
4808-
4809#if defined (ARRAY_VARS)-
4810/* When this is called, it's guaranteed that we don't care about anything-
4811 in t beyond i. We use a buffer with room for the characters we add just-
4812 in case assignment() ends up doing something like parsing a command-
4813 substitution that will reallocate atoken. We don't want to write beyond-
4814 the end of an allocated buffer. */-
4815static int-
4816token_is_assignment (t, i)-
4817 char *t;-
4818 int i;-
4819{-
4820 int r;-
4821 char *atoken;-
4822-
4823 atoken = xmalloc (i + 3);-
4824 memcpy (atoken, t, i);-
4825 atoken[i] = '=';-
4826 atoken[i+1] = '\0';-
4827-
4828 r = assignment (atoken, (parser_state & PST_COMPASSIGN) != 0);-
4829-
4830 free (atoken);-
4831-
4832 /* XXX - check that r == i to avoid returning false positive for-
4833 t containing `=' before t[i]. */-
4834 return (r > 0 && r == i);
executed 119104 times by 1 test: return (r > 0 && r == i);
Executed by:
  • Self test
119104
4835}-
4836-
4837/* XXX - possible changes here for `+=' */-
4838static int-
4839token_is_ident (t, i)-
4840 char *t;-
4841 int i;-
4842{-
4843 unsigned char c;-
4844 int r;-
4845-
4846 c = t[i];-
4847 t[i] = '\0';-
4848 r = legal_identifier (t);-
4849 t[i] = c;-
4850 return r;
executed 967 times by 1 test: return r;
Executed by:
  • Self test
967
4851}-
4852#endif-
4853-
4854static int-
4855read_token_word (character)-
4856 int character;-
4857{-
4858 /* The value for YYLVAL when a WORD is read. */-
4859 WORD_DESC *the_word;-
4860-
4861 /* Index into the token that we are building. */-
4862 int token_index;-
4863-
4864 /* ALL_DIGITS becomes zero when we see a non-digit. */-
4865 int all_digit_token;-
4866-
4867 /* DOLLAR_PRESENT becomes non-zero if we see a `$'. */-
4868 int dollar_present;-
4869-
4870 /* COMPOUND_ASSIGNMENT becomes non-zero if we are parsing a compound-
4871 assignment. */-
4872 int compound_assignment;-
4873-
4874 /* QUOTED becomes non-zero if we see one of ("), ('), (`), or (\). */-
4875 int quoted;-
4876-
4877 /* Non-zero means to ignore the value of the next character, and just-
4878 to add it no matter what. */-
4879 int pass_next_character;-
4880-
4881 /* The current delimiting character. */-
4882 int cd;-
4883 int result, peek_char;-
4884 char *ttok, *ttrans;-
4885 int ttoklen, ttranslen;-
4886 intmax_t lvalue;-
4887-
4888 if (token_buffer_size < TOKEN_DEFAULT_INITIAL_SIZE)
token_buffer_size < 496Description
TRUEevaluated 713316 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2160912 times by 1 test
Evaluated by:
  • Self test
713316-2160912
4889 token = (char *)xrealloc (token, token_buffer_size = TOKEN_DEFAULT_INITIAL_SIZE);
executed 713316 times by 1 test: token = (char *)sh_xrealloc((token), (token_buffer_size = 496), "./parse.y", 4889);
Executed by:
  • Self test
713316
4890-
4891 token_index = 0;-
4892 all_digit_token = DIGIT (character);
(character) >= '0'Description
TRUEevaluated 2354832 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 519396 times by 1 test
Evaluated by:
  • Self test
(character) <= '9'Description
TRUEevaluated 93549 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2261283 times by 1 test
Evaluated by:
  • Self test
93549-2354832
4893 dollar_present = quoted = pass_next_character = compound_assignment = 0;-
4894-
4895 for (;;)-
4896 {-
4897 if (character == EOF)
character == (-1)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11138507 times by 1 test
Evaluated by:
  • Self test
3-11138507
4898 goto got_token;
executed 3 times by 1 test: goto got_token;
Executed by:
  • Self test
3
4899-
4900 if (pass_next_character)
pass_next_characterDescription
TRUEevaluated 1260 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11137247 times by 1 test
Evaluated by:
  • Self test
1260-11137247
4901 {-
4902 pass_next_character = 0;-
4903 goto got_escaped_character;
executed 1260 times by 1 test: goto got_escaped_character;
Executed by:
  • Self test
1260
4904 }-
4905-
4906 cd = current_delimiter (dstack);
dstack.delimiter_depthDescription
TRUEnever evaluated
FALSEevaluated 11137247 times by 1 test
Evaluated by:
  • Self test
0-11137247
4907-
4908 /* Handle backslashes. Quote lots of things when not inside of-
4909 double-quotes, quote some things inside of double-quotes. */-
4910 if MBTEST(character == '\\')
(shell_input_line_index > 1)Description
TRUEevaluated 1243 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
(character == '\\')Description
TRUEevaluated 1260 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11135987 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 1260 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11135987
4911 {-
4912 peek_char = shell_getc (0);-
4913-
4914 /* Backslash-newline is ignored in all cases except-
4915 when quoted with single quotes. */-
4916 if (peek_char == '\n')
peek_char == '\n'Description
TRUEnever evaluated
FALSEevaluated 1260 times by 1 test
Evaluated by:
  • Self test
0-1260
4917 {-
4918 character = '\n';-
4919 goto next_character;
never executed: goto next_character;
0
4920 }-
4921 else-
4922 {-
4923 shell_ungetc (peek_char);-
4924-
4925 /* If the next character is to be quoted, note it now. */-
4926 if (cd == 0 || cd == '`' ||
cd == 0Description
TRUEevaluated 1260 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
cd == '`'Description
TRUEnever evaluated
FALSEnever evaluated
0-1260
4927 (cd == '"' && peek_char >= 0 && (sh_syntaxtab[peek_char] & CBSDQUOTE)))
cd == '"'Description
TRUEnever evaluated
FALSEnever evaluated
peek_char >= 0Description
TRUEnever evaluated
FALSEnever evaluated
(sh_syntaxtab[...har] & 0x0040)Description
TRUEnever evaluated
FALSEnever evaluated
0
4928 pass_next_character++;
executed 1260 times by 1 test: pass_next_character++;
Executed by:
  • Self test
1260
4929-
4930 quoted = 1;-
4931 goto got_character;
executed 1260 times by 1 test: goto got_character;
Executed by:
  • Self test
1260
4932 }-
4933 }-
4934-
4935 /* Parse a matched pair of quote characters. */-
4936 if MBTEST(shellquote (character))
(shell_input_line_index > 1)Description
TRUEevaluated 364499 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 153 times by 1 test
Evaluated by:
  • Self test
((sh_syntaxtab...r)] & 0x0008))Description
TRUEevaluated 364652 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10771335 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 364652 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10771335
4937 {-
4938 push_delimiter (dstack, character);
executed 3294 times by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 4938);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 3294 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 361358 times by 1 test
Evaluated by:
  • Self test
3294-361358
4939 ttok = parse_matched_pair (character, character, character, &ttoklen, (character == '`') ? P_COMMAND : 0);-
4940 pop_delimiter (dstack);-
4941 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 364651 times by 1 test
Evaluated by:
  • Self test
1-364651
4942 return -1; /* Bail immediately. */
executed 1 time by 1 test: return -1;
Executed by:
  • Self test
1
4943 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 364651 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-364651
4944 token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);-
4945 token[token_index++] = character;-
4946 strcpy (token + token_index, ttok);-
4947 token_index += ttoklen;-
4948 all_digit_token = 0;-
4949 quoted = 1;-
4950 dollar_present |= (character == '"' && strchr (ttok, '$') != 0);
character == '"'Description
TRUEevaluated 146931 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 217720 times by 1 test
Evaluated by:
  • Self test
(__extension__..., '$' ))) != 0Description
TRUEevaluated 115125 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31806 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( '$' )Description
TRUEevaluated 146931 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!__builtin_constant_p ( ttok )Description
TRUEevaluated 146931 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
( '$' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 146931 times by 1 test
Evaluated by:
  • Self test
0-217720
4951 FREE (ttok);
executed 364651 times by 1 test: sh_xfree((ttok), "./parse.y", 4951);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 364651 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-364651
4952 goto next_character;
executed 364651 times by 1 test: goto next_character;
Executed by:
  • Self test
364651
4953 }-
4954-
4955#ifdef COND_REGEXP-
4956 /* When parsing a regexp as a single word inside a conditional command,-
4957 we need to special-case characters special to both the shell and-
4958 regular expressions. Right now, that is only '(' and '|'. */ /*)*/-
4959 if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
(shell_input_line_index > 1)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(parser_state & 0x010000)Description
TRUEevaluated 459 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10770876 times by 1 test
Evaluated by:
  • Self test
character == '('Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 431 times by 1 test
Evaluated by:
  • Self test
character == '|'Description
TRUEnever evaluated
FALSEevaluated 431 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10770876
4960 {-
4961 if (character == '|')
character == '|'Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
4962 goto got_character;
never executed: goto got_character;
0
4963-
4964 push_delimiter (dstack, character);
never executed: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 4964);
dstack.delimit...elimiter_spaceDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
4965 ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);-
4966 pop_delimiter (dstack);-
4967 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
4968 return -1; /* Bail immediately. */
never executed: return -1;
0
4969 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-28
4970 token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);-
4971 token[token_index++] = character;-
4972 strcpy (token + token_index, ttok);-
4973 token_index += ttoklen;-
4974 FREE (ttok);
executed 28 times by 1 test: sh_xfree((ttok), "./parse.y", 4974);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28
4975 dollar_present = all_digit_token = 0;-
4976 goto next_character;
executed 28 times by 1 test: goto next_character;
Executed by:
  • Self test
28
4977 }-
4978#endif /* COND_REGEXP */-
4979-
4980#ifdef EXTENDED_GLOB-
4981 /* Parse a ksh-style extended pattern matching specification. */-
4982 if MBTEST(extended_glob && PATTERN_CHAR (character))
(shell_input_line_index > 1)Description
TRUEevaluated 702 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
extended_globDescription
TRUEevaluated 49661 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10721646 times by 1 test
Evaluated by:
  • Self test
(character) == '@'Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49591 times by 1 test
Evaluated by:
  • Self test
(character) == '*'Description
TRUEevaluated 412 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49179 times by 1 test
Evaluated by:
  • Self test
(character) == '+'Description
TRUEevaluated 145 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49034 times by 1 test
Evaluated by:
  • Self test
(character) == '?'Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48968 times by 1 test
Evaluated by:
  • Self test
(character) == '!'Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48892 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 769 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10721646
4983 {-
4984 peek_char = shell_getc (1);-
4985 if MBTEST(peek_char == '(') /* ) */
(shell_input_line_index > 1)Description
TRUEevaluated 199 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '(')Description
TRUEevaluated 199 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 570 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 199 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-570
4986 {-
4987 push_delimiter (dstack, peek_char);
executed 4 times by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 4987);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 195 times by 1 test
Evaluated by:
  • Self test
4-195
4988 ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);-
4989 pop_delimiter (dstack);-
4990 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 199 times by 1 test
Evaluated by:
  • Self test
0-199
4991 return -1; /* Bail immediately. */
never executed: return -1;
0
4992 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 3,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 199 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-199
4993 token_buffer_size,-
4994 TOKEN_DEFAULT_GROW_SIZE);-
4995 token[token_index++] = character;-
4996 token[token_index++] = peek_char;-
4997 strcpy (token + token_index, ttok);-
4998 token_index += ttoklen;-
4999 FREE (ttok);
executed 199 times by 1 test: sh_xfree((ttok), "./parse.y", 4999);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 199 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-199
5000 dollar_present = all_digit_token = 0;-
5001 goto next_character;
executed 199 times by 1 test: goto next_character;
Executed by:
  • Self test
199
5002 }-
5003 else-
5004 shell_ungetc (peek_char);
executed 570 times by 1 test: shell_ungetc (peek_char);
Executed by:
  • Self test
570
5005 }-
5006#endif /* EXTENDED_GLOB */-
5007-
5008 /* If the delimiter character is not single quote, parse some of-
5009 the shell expansions that must be read as a single word. */-
5010 if (shellexp (character))
(character) == '$'Description
TRUEevaluated 189730 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10581378 times by 1 test
Evaluated by:
  • Self test
(character) == '<'Description
TRUEevaluated 17717 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10563661 times by 1 test
Evaluated by:
  • Self test
(character) == '>'Description
TRUEevaluated 6739 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10556922 times by 1 test
Evaluated by:
  • Self test
6739-10581378
5011 {-
5012 peek_char = shell_getc (1);-
5013 /* $(...), <(...), >(...), $((...)), ${...}, and $[...] constructs */-
5014 if MBTEST(peek_char == '(' ||
(shell_input_line_index > 1)Description
TRUEevaluated 37971 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
peek_char == '('Description
TRUEevaluated 23338 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 190848 times by 1 test
Evaluated by:
  • Self test
peek_char == '{'Description
TRUEevaluated 14630 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 176218 times by 1 test
Evaluated by:
  • Self test
peek_char == '['Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 176215 times by 1 test
Evaluated by:
  • Self test
character == '$'Description
TRUEevaluated 14633 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 37971 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-190848
5015 ((peek_char == '{' || peek_char == '[') && character == '$')) /* ) ] } */-
5016 {-
5017 if (peek_char == '{') /* } */
peek_char == '{'Description
TRUEevaluated 14630 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23341 times by 1 test
Evaluated by:
  • Self test
14630-23341
5018 ttok = parse_matched_pair (cd, '{', '}', &ttoklen, P_FIRSTCLOSE|P_DOLBRACE);
executed 14630 times by 1 test: ttok = parse_matched_pair (cd, '{', '}', &ttoklen, 0x0001|0x0040);
Executed by:
  • Self test
14630
5019 else if (peek_char == '(') /* ) */
peek_char == '('Description
TRUEevaluated 23338 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-23338
5020 {-
5021 /* XXX - push and pop the `(' as a delimiter for use by-
5022 the command-oriented-history code. This way newlines-
5023 appearing in the $(...) string get added to the-
5024 history literally rather than causing a possibly--
5025 incorrect `;' to be added. ) */-
5026 push_delimiter (dstack, peek_char);
executed 1509 times by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 5026);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 1509 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21829 times by 1 test
Evaluated by:
  • Self test
1509-21829
5027 ttok = parse_comsub (cd, '(', ')', &ttoklen, P_COMMAND);-
5028 pop_delimiter (dstack);-
5029 }
executed 23338 times by 1 test: end of block
Executed by:
  • Self test
23338
5030 else-
5031 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
executed 3 times by 1 test: ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
Executed by:
  • Self test
3
5032 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37967 times by 1 test
Evaluated by:
  • Self test
4-37967
5033 return -1; /* Bail immediately. */
executed 4 times by 1 test: return -1;
Executed by:
  • Self test
4
5034 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 3,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 37967 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-37967
5035 token_buffer_size,-
5036 TOKEN_DEFAULT_GROW_SIZE);-
5037 token[token_index++] = character;-
5038 token[token_index++] = peek_char;-
5039 strcpy (token + token_index, ttok);-
5040 token_index += ttoklen;-
5041 FREE (ttok);
executed 37967 times by 1 test: sh_xfree((ttok), "./parse.y", 5041);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 37967 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-37967
5042 dollar_present = 1;-
5043 all_digit_token = 0;-
5044 goto next_character;
executed 37967 times by 1 test: goto next_character;
Executed by:
  • Self test
37967
5045 }-
5046 /* This handles $'...' and $"..." new-style quoted strings. */-
5047 else if MBTEST(character == '$' && (peek_char == '\'' || peek_char == '"'))
(shell_input_line_index > 1)Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '$'Description
TRUEevaluated 170218 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5997 times by 1 test
Evaluated by:
  • Self test
peek_char == '\''Description
TRUEevaluated 2495 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 167723 times by 1 test
Evaluated by:
  • Self test
peek_char == '"'Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 167688 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-170218
5048 {-
5049 int first_line;-
5050-
5051 first_line = line_number;-
5052 push_delimiter (dstack, peek_char);
executed 44 times by 1 test: dstack.delimiters = (char *)sh_xrealloc((dstack.delimiters), ((dstack.delimiter_space += 10) * sizeof (char)), "./parse.y", 5052);
Executed by:
  • Self test
dstack.delimit...elimiter_spaceDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2486 times by 1 test
Evaluated by:
  • Self test
44-2486
5053 ttok = parse_matched_pair (peek_char, peek_char, peek_char,-
5054 &ttoklen,-
5055 (peek_char == '\'') ? P_ALLOWESC : 0);-
5056 pop_delimiter (dstack);-
5057 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
0-2530
5058 return -1;
never executed: return -1;
0
5059 if (peek_char == '\'')
peek_char == '\''Description
TRUEevaluated 2495 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
35-2495
5060 {-
5061 ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);-
5062 free (ttok);-
5063-
5064 /* Insert the single quotes and correctly quote any-
5065 embedded single quotes (allowed because P_ALLOWESC was-
5066 passed to parse_matched_pair). */-
5067 ttok = sh_single_quote (ttrans);-
5068 free (ttrans);-
5069 ttranslen = strlen (ttok);-
5070 ttrans = ttok;-
5071 }
executed 2495 times by 1 test: end of block
Executed by:
  • Self test
2495
5072 else-
5073 {-
5074 /* Try to locale-expand the converted string. */-
5075 ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);-
5076 free (ttok);-
5077-
5078 /* Add the double quotes back */-
5079 ttok = sh_mkdoublequoted (ttrans, ttranslen, 0);-
5080 free (ttrans);-
5081 ttranslen += 2;-
5082 ttrans = ttok;-
5083 }
executed 35 times by 1 test: end of block
Executed by:
  • Self test
35
5084-
5085 RESIZE_MALLOCED_BUFFER (token, token_index, ttranslen + 1,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-2530
5086 token_buffer_size,-
5087 TOKEN_DEFAULT_GROW_SIZE);-
5088 strcpy (token + token_index, ttrans);-
5089 token_index += ttranslen;-
5090 FREE (ttrans);
executed 2530 times by 1 test: sh_xfree((ttrans), "./parse.y", 5090);
Executed by:
  • Self test
ttransDescription
TRUEevaluated 2530 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2530
5091 quoted = 1;-
5092 all_digit_token = 0;-
5093 goto next_character;
executed 2530 times by 1 test: goto next_character;
Executed by:
  • Self test
2530
5094 }-
5095 /* This could eventually be extended to recognize all of the-
5096 shell's single-character parameter expansions, and set flags.*/-
5097 else if MBTEST(character == '$' && peek_char == '$')
(shell_input_line_index > 1)Description
TRUEevaluated 1253 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '$'Description
TRUEevaluated 167688 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5997 times by 1 test
Evaluated by:
  • Self test
peek_char == '$'Description
TRUEevaluated 1253 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 166435 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 1253 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-167688
5098 {-
5099 RESIZE_MALLOCED_BUFFER (token, token_index, 3,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 1253 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-1253
5100 token_buffer_size,-
5101 TOKEN_DEFAULT_GROW_SIZE);-
5102 token[token_index++] = '$';-
5103 token[token_index++] = peek_char;-
5104 dollar_present = 1;-
5105 all_digit_token = 0;-
5106 goto next_character;
executed 1253 times by 1 test: goto next_character;
Executed by:
  • Self test
1253
5107 }-
5108 else-
5109 shell_ungetc (peek_char);
executed 172432 times by 1 test: shell_ungetc (peek_char);
Executed by:
  • Self test
172432
5110 }-
5111-
5112#if defined (ARRAY_VARS)-
5113 /* Identify possible array subscript assignment; match [...]. If-
5114 parser_state&PST_COMPASSIGN, we need to parse [sub]=words treating-
5115 `sub' as if it were enclosed in double quotes. */-
5116 else if MBTEST(character == '[' && /* ] */
(shell_input_line_index > 1)Description
TRUEevaluated 4440 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 126 times by 1 test
Evaluated by:
  • Self test
character == '['Description
TRUEevaluated 6788 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10550134 times by 1 test
Evaluated by:
  • Self test
token_index > 0Description
TRUEevaluated 1459 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5329 times by 1 test
Evaluated by:
  • Self test
((last_read_token) == 282)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1454 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x080000)Description
TRUEnever evaluated
FALSEevaluated 1454 times by 1 test
Evaluated by:
  • Self test
(last_read_tok...n == 299) == 0Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == '<'Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == '>'Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 290Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 302Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 301Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 298Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 291Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 293Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 292Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 294Description
TRUEnever evaluated
FALSEnever evaluated
last_read_token == 299Description
TRUEnever evaluated
FALSEnever evaluated
(last_read_token) != 295Description
TRUEevaluated 1454 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 296Description
TRUEevaluated 1454 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 297Description
TRUEevaluated 1454 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
reserved_word_...st_read_token)Description
TRUEevaluated 1049 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 405 times by 1 test
Evaluated by:
  • Self test
((parser_state...x000001) == 0)Description
TRUEevaluated 967 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 87 times by 1 test
Evaluated by:
  • Self test
token_is_ident..., token_index)Description
TRUEevaluated 391 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 576 times by 1 test
Evaluated by:
  • Self test
token_index == 0Description
TRUEevaluated 5329 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1068 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x002000)Description
TRUEevaluated 4175 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1154 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 4566 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10550134
5117 ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) ||-
5118 (token_index == 0 && (parser_state&PST_COMPASSIGN))))-
5119 {-
5120 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB);-
5121 if (ttok == &matched_pair_error)
ttok == &matched_pair_errorDescription
TRUEnever evaluated
FALSEevaluated 4566 times by 1 test
Evaluated by:
  • Self test
0-4566
5122 return -1; /* Bail immediately. */
never executed: return -1;
0
5123 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 4566 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-4566
5124 token_buffer_size,-
5125 TOKEN_DEFAULT_GROW_SIZE);-
5126 token[token_index++] = character;-
5127 strcpy (token + token_index, ttok);-
5128 token_index += ttoklen;-
5129 FREE (ttok);
executed 4566 times by 1 test: sh_xfree((ttok), "./parse.y", 5129);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 4566 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4566
5130 all_digit_token = 0;-
5131 goto next_character;
executed 4566 times by 1 test: goto next_character;
Executed by:
  • Self test
4566
5132 }-
5133 /* Identify possible compound array variable assignment. */-
5134 else if MBTEST(character == '=' && token_index > 0 && (assignment_acceptable (last_read_token) || (parser_state & PST_ASSIGNOK)) && token_is_assignment (token, token_index))
(shell_input_line_index > 1)Description
TRUEevaluated 119028 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
character == '='Description
TRUEevaluated 129193 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10423163 times by 1 test
Evaluated by:
  • Self test
token_index > 0Description
TRUEevaluated 128405 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 788 times by 1 test
Evaluated by:
  • Self test
((last_read_token) == 282)Description
TRUEevaluated 9187 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 119218 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x080000)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 119215 times by 1 test
Evaluated by:
  • Self test
(last_read_tok...n == 299) == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_read_token == '<'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == '>'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 290Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 302Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 301Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 298Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 291Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 293Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 299Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(last_read_token) != 295Description
TRUEevaluated 119215 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 296Description
TRUEevaluated 119215 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 297Description
TRUEevaluated 119215 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
reserved_word_...st_read_token)Description
TRUEevaluated 106048 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13167 times by 1 test
Evaluated by:
  • Self test
((parser_state...x000001) == 0)Description
TRUEevaluated 115231 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(parser_state & 0x004000)Description
TRUEevaluated 3873 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9301 times by 1 test
Evaluated by:
  • Self test
token_is_assig..., token_index)Description
TRUEevaluated 119028 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 119028 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10423163
5135 {-
5136 peek_char = shell_getc (1);-
5137 if MBTEST(peek_char == '(') /* ) */
(shell_input_line_index > 1)Description
TRUEevaluated 725 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(peek_char == '(')Description
TRUEevaluated 725 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 118303 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 725 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-118303
5138 {-
5139 ttok = parse_compound_assignment (&ttoklen);-
5140-
5141 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 4,
executed 38 times by 1 test: token_buffer_size += (512);
Executed by:
  • Self test
executed 2 times by 1 test: end of block
Executed by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 706 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-706
5142 token_buffer_size,-
5143 TOKEN_DEFAULT_GROW_SIZE);-
5144-
5145 token[token_index++] = '=';-
5146 token[token_index++] = '(';-
5147 if (ttok)
ttokDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
64-644
5148 {-
5149 strcpy (token + token_index, ttok);-
5150 token_index += ttoklen;-
5151 }
executed 644 times by 1 test: end of block
Executed by:
  • Self test
644
5152 token[token_index++] = ')';-
5153 FREE (ttok);
executed 644 times by 1 test: sh_xfree((ttok), "./parse.y", 5153);
Executed by:
  • Self test
ttokDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
64-644
5154 all_digit_token = 0;-
5155 compound_assignment = 1;-
5156#if 1-
5157 goto next_character;
executed 708 times by 1 test: goto next_character;
Executed by:
  • Self test
708
5158#else-
5159 goto got_token; /* ksh93 seems to do this */-
5160#endif-
5161 }-
5162 else-
5163 shell_ungetc (peek_char);
executed 118303 times by 1 test: shell_ungetc (peek_char);
Executed by:
  • Self test
118303
5164 }-
5165#endif-
5166-
5167 /* When not parsing a multi-character word construct, shell meta--
5168 characters break words. */-
5169 if MBTEST(shellbreak (character))
(shell_input_line_index > 1)Description
TRUEevaluated 2874166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
((sh_syntaxtab...r)] & 0x0002))Description
TRUEevaluated 2874203 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7849860 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2874203 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7849860
5170 {-
5171 shell_ungetc (character);-
5172 goto got_token;
executed 2874203 times by 1 test: goto got_token;
Executed by:
  • Self test
2874203
5173 }-
5174-
5175got_character:
code before this statement executed 7849860 times by 1 test: got_character:
Executed by:
  • Self test
7849860
5176 if (character == CTLESC || character == CTLNUL)
character == '\001'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7851101 times by 1 test
Evaluated by:
  • Self test
character == '\177'Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7851083 times by 1 test
Evaluated by:
  • Self test
18-7851101
5177 {-
5178 RESIZE_MALLOCED_BUFFER (token, token_index, 2, token_buffer_size,
never executed: token_buffer_size += (512);
never executed: end of block
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-37
5179 TOKEN_DEFAULT_GROW_SIZE);-
5180 token[token_index++] = CTLESC;-
5181 }
executed 37 times by 1 test: end of block
Executed by:
  • Self test
37
5182 else-
5183got_escaped_character:-
5184 RESIZE_MALLOCED_BUFFER (token, token_index, 1, token_buffer_size,
executed 195 times by 1 test: token_buffer_size += (512);
Executed by:
  • Self test
executed 195 times by 1 test: end of block
Executed by:
  • Self test
executed 7852343 times by 1 test: end of block
Executed by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEevaluated 195 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7852148 times by 1 test
Evaluated by:
  • Self test
(token_index) ...en_buffer_sizeDescription
TRUEevaluated 195 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 195 times by 1 test
Evaluated by:
  • Self test
195-7852343
5185 TOKEN_DEFAULT_GROW_SIZE);-
5186-
5187 token[token_index++] = character;-
5188-
5189 all_digit_token &= DIGIT (character);
(character) >= '0'Description
TRUEevaluated 7522018 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 330362 times by 1 test
Evaluated by:
  • Self test
(character) <= '9'Description
TRUEevaluated 278894 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7243124 times by 1 test
Evaluated by:
  • Self test
278894-7522018
5190 dollar_present |= character == '$';-
5191-
5192 next_character:
code before this statement executed 7852380 times by 1 test: next_character:
Executed by:
  • Self test
7852380
5193 if (character == '\n' && SHOULD_PROMPT ())
character == '\n'Description
TRUEnever evaluated
FALSEevaluated 8264282 times by 1 test
Evaluated by:
  • Self test
interactiveDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-8264282
5194 prompt_again ();
never executed: prompt_again ();
0
5195-
5196 /* We want to remove quoted newlines (that is, a \<newline> pair)-
5197 unless we are within single quotes or pass_next_character is-
5198 set (the shell equivalent of literal-next). */-
5199 cd = current_delimiter (dstack);
dstack.delimiter_depthDescription
TRUEnever evaluated
FALSEevaluated 8264282 times by 1 test
Evaluated by:
  • Self test
0-8264282
5200 character = shell_getc (cd != '\'' && pass_next_character == 0);-
5201 } /* end for (;;) */
executed 8264282 times by 1 test: end of block
Executed by:
  • Self test
8264282
5202-
5203got_token:
code before this statement never executed: got_token:
0
5204-
5205 /* Calls to RESIZE_MALLOCED_BUFFER ensure there is sufficient room. */-
5206 token[token_index] = '\0';-
5207-
5208 /* Check to see what thing we should return. If the last_read_token-
5209 is a `<', or a `&', or the character which ended this token is-
5210 a '>' or '<', then, and ONLY then, is this input token a NUMBER.-
5211 Otherwise, it is just a word, and should be returned as such. */-
5212 if MBTEST(all_digit_token && (character == '<' || character == '>' ||
(shell_input_line_index > 1)Description
TRUEevaluated 27204 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
all_digit_tokenDescription
TRUEevaluated 93125 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2781081 times by 1 test
Evaluated by:
  • Self test
character == '<'Description
TRUEevaluated 1484 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91641 times by 1 test
Evaluated by:
  • Self test
character == '>'Description
TRUEevaluated 4430 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 87211 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 87181 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEevaluated 21260 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65921 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 27204 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2781081
5213 last_read_token == LESS_AND ||-
5214 last_read_token == GREATER_AND))-
5215 {-
5216 if (legal_number (token, &lvalue) && (int)lvalue == lvalue)
legal_number (token, &lvalue)Description
TRUEevaluated 27196 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
(int)lvalue == lvalueDescription
TRUEevaluated 27196 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-27196
5217 {-
5218 yylval.number = lvalue;-
5219 return (NUMBER);
executed 27196 times by 1 test: return (284);
Executed by:
  • Self test
27196
5220 }-
5221 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
5222-
5223 /* Check for special case tokens. */-
5224 result = (last_shell_getc_is_singlebyte) ? special_case_tokens (token) : -1;
(((shell_input...dex - 1] : 1))Description
TRUEevaluated 2847007 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(shell_input_line_index > 1)Description
TRUEevaluated 2830960 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16050 times by 1 test
Evaluated by:
  • Self test
3-2847007
5225 if (result >= 0)
result >= 0Description
TRUEevaluated 128189 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2718821 times by 1 test
Evaluated by:
  • Self test
128189-2718821
5226 return result;
executed 128189 times by 1 test: return result;
Executed by:
  • Self test
128189
5227-
5228#if defined (ALIAS)-
5229 /* Posix.2 does not allow reserved words to be aliased, so check for all-
5230 of them, including special cases, before expanding the current token-
5231 as an alias. */-
5232 if MBTEST(posixly_correct)
(shell_input_line_index > 1)Description
TRUEevaluated 9758 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
(posixly_correct)Description
TRUEevaluated 9770 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2709051 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 9770 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2709051
5233 CHECK_FOR_RESERVED_WORD (token);
never executed: __result = (((const unsigned char *) (const char *) ( token ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( word_token_alist[i].word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: break;
never executed: break;
never executed: break;
executed 1 time by 1 test: parser_state &= ~(0x000001|0x000080);
Executed by:
  • Self test
executed 1 time by 1 test: parser_state |= 0x000080;
Executed by:
  • Self test
never executed: parser_state &= ~(0x000100|0x000200);
executed 6 times by 1 test: parser_state |= 0x000100;
Executed by:
  • Self test
executed 1 time by 1 test: open_brace_count++;
Executed by:
  • Self test
never executed: open_brace_count--;
executed 35 times by 1 test: return (word_token_alist[i].token);
Executed by:
  • Self test
executed 3133 times by 1 test: end of block
Executed by:
  • Self test
executed 9735 times by 1 test: end of block
Executed by:
  • Self test
word_token_ali...].token == 264Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 263Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 274Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 273Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == '{'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
word_token_ali...*) ((void *)0)Description
TRUEevaluated 69188 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3133 times by 1 test
Evaluated by:
  • Self test
!dollar_presentDescription
TRUEevaluated 8418 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1352 times by 1 test
Evaluated by:
  • Self test
!quotedDescription
TRUEevaluated 7842 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 576 times by 1 test
Evaluated by:
  • Self test
reserved_word_...st_read_token)Description
TRUEevaluated 3168 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4674 times by 1 test
Evaluated by:
  • Self test
(token)[0] == ...st[i].word)[0]Description
TRUEevaluated 7297 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61891 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7262 times by 1 test
Evaluated by:
  • Self test
__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
(parser_state & 0x000001)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
(word_token_al....token != 264)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 278Description
TRUEnever evaluated
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
time_command_a...ptable () == 0Description
TRUEnever evaluated
FALSEnever evaluated
(parser_state & 0x000001)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
last_read_token == '|'Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 264Description
TRUEnever evaluated
FALSEnever evaluated
word_token_ali...].token == '}'Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
open_brace_countDescription
TRUEnever evaluated
FALSEnever evaluated
0-69188
5234-
5235 /* Aliases are expanded iff EXPAND_ALIASES is non-zero, and quoting-
5236 inhibits alias expansion. */-
5237 if (expand_aliases && quoted == 0)
expand_aliasesDescription
TRUEevaluated 18628 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2700158 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 16242 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2386 times by 1 test
Evaluated by:
  • Self test
2386-2700158
5238 {-
5239 result = alias_expand_token (token);-
5240 if (result == RE_READ_TOKEN)
result == -99Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16160 times by 1 test
Evaluated by:
  • Self test
82-16160
5241 return (RE_READ_TOKEN);
executed 82 times by 1 test: return (-99);
Executed by:
  • Self test
82
5242 else if (result == NO_EXPANSION)
result == -100Description
TRUEevaluated 16160 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-16160
5243 parser_state &= ~PST_ALEXPNEXT;
executed 16160 times by 1 test: parser_state &= ~0x000002;
Executed by:
  • Self test
16160
5244 }
executed 16160 times by 1 test: end of block
Executed by:
  • Self test
16160
5245-
5246 /* If not in Posix.2 mode, check for reserved words after alias-
5247 expansion. */-
5248 if MBTEST(posixly_correct == 0)
(shell_input_line_index > 1)Description
TRUEevaluated 2705105 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3864 times by 1 test
Evaluated by:
  • Self test
(posixly_correct == 0)Description
TRUEevaluated 2708969 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9735 times by 1 test
Evaluated by:
  • Self test
((shell_input_...ndex - 1] : 1)Description
TRUEevaluated 2708966 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-2708969
5249#endif-
5250 CHECK_FOR_RESERVED_WORD (token);
never executed: __result = (((const unsigned char *) (const char *) ( token ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( word_token_alist[i].word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: break;
never executed: break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
executed 78108 times by 1 test: parser_state &= ~(0x000001|0x000080);
Executed by:
  • Self test
executed 78111 times by 1 test: parser_state |= 0x000080;
Executed by:
  • Self test
never executed: parser_state &= ~(0x000100|0x000200);
executed 568 times by 1 test: parser_state |= 0x000100;
Executed by:
  • Self test
executed 824 times by 1 test: open_brace_count++;
Executed by:
  • Self test
never executed: open_brace_count--;
executed 262804 times by 1 test: return (word_token_alist[i].token);
Executed by:
  • Self test
executed 1056929 times by 1 test: end of block
Executed by:
  • Self test
executed 2446162 times by 1 test: end of block
Executed by:
  • Self test
word_token_ali...].token == 264Description
TRUEevaluated 78108 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 184696 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 263Description
TRUEevaluated 78111 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106585 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 274Description
TRUEnever evaluated
FALSEevaluated 106585 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 273Description
TRUEevaluated 568 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106017 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == '{'Description
TRUEevaluated 824 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 105193 times by 1 test
Evaluated by:
  • Self test
word_token_ali...*) ((void *)0)Description
TRUEevaluated 25421298 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1056927 times by 1 test
Evaluated by:
  • Self test
!dollar_presentDescription
TRUEevaluated 2420992 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 287974 times by 1 test
Evaluated by:
  • Self test
!quotedDescription
TRUEevaluated 2169380 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 251612 times by 1 test
Evaluated by:
  • Self test
reserved_word_...st_read_token)Description
TRUEevaluated 1319733 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 849647 times by 1 test
Evaluated by:
  • Self test
(token)[0] == ...st[i].word)[0]Description
TRUEevaluated 2951772 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22469526 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 262806 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2688966 times by 1 test
Evaluated by:
  • Self test
__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
(parser_state & 0x000001)Description
TRUEevaluated 75603 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 187203 times by 1 test
Evaluated by:
  • Self test
(word_token_al....token != 264)Description
TRUEnever evaluated
FALSEevaluated 75603 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 278Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 262791 times by 1 test
Evaluated by:
  • Self test
time_command_a...ptable () == 0Description
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
(parser_state & 0x000001)Description
TRUEevaluated 75603 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 187203 times by 1 test
Evaluated by:
  • Self test
last_read_token == '|'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75601 times by 1 test
Evaluated by:
  • Self test
word_token_ali...].token == 264Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
word_token_ali...].token == '}'Description
TRUEnever evaluated
FALSEevaluated 105193 times by 1 test
Evaluated by:
  • Self test
open_brace_countDescription
TRUEnever evaluated
FALSEnever evaluated
0-25421298
5251-
5252 the_word = alloc_word_desc ();-
5253 the_word->word = (char *)xmalloc (1 + token_index);-
5254 the_word->flags = 0;-
5255 strcpy (the_word->word, token);-
5256 if (dollar_present)
dollar_presentDescription
TRUEevaluated 289326 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2166574 times by 1 test
Evaluated by:
  • Self test
289326-2166574
5257 the_word->flags |= W_HASDOLLAR;
executed 289326 times by 1 test: the_word->flags |= 0x000001;
Executed by:
  • Self test
289326
5258 if (quoted)
quotedDescription
TRUEevaluated 367512 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2088388 times by 1 test
Evaluated by:
  • Self test
367512-2088388
5259 the_word->flags |= W_QUOTED; /*(*/
executed 367512 times by 1 test: the_word->flags |= 0x000002;
Executed by:
  • Self test
367512
5260 if (compound_assignment && token[token_index-1] == ')')
compound_assignmentDescription
TRUEevaluated 708 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2455192 times by 1 test
Evaluated by:
  • Self test
token[token_index-1] == ')'Description
TRUEevaluated 706 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-2455192
5261 the_word->flags |= W_COMPASSIGN;
executed 706 times by 1 test: the_word->flags |= 0x008000;
Executed by:
  • Self test
706
5262 /* A word is an assignment if it appears at the beginning of a-
5263 simple command, or after another assignment word. This is-
5264 context-dependent, so it cannot be handled in the grammar. */-
5265 if (assignment (token, (parser_state & PST_COMPASSIGN) != 0))
assignment (to...x002000) != 0)Description
TRUEevaluated 127764 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2328136 times by 1 test
Evaluated by:
  • Self test
127764-2328136
5266 {-
5267 the_word->flags |= W_ASSIGNMENT;-
5268 /* Don't perform word splitting on assignment statements. */-
5269 if (assignment_acceptable (last_read_token) || (parser_state & PST_COMPASSIGN) != 0)
((last_read_token) == 282)Description
TRUEevaluated 9187 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 118577 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x080000)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 118574 times by 1 test
Evaluated by:
  • Self test
(last_read_tok...n == 299) == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_read_token == '<'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == '>'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 290Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 302Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 301Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 298Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 291Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 293Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
last_read_token == 299Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(last_read_token) != 295Description
TRUEevaluated 118574 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 296Description
TRUEevaluated 118574 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 297Description
TRUEevaluated 118574 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
reserved_word_...st_read_token)Description
TRUEevaluated 105986 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12588 times by 1 test
Evaluated by:
  • Self test
((parser_state...x000001) == 0)Description
TRUEevaluated 115176 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(parser_state & 0x002000) != 0Description
TRUEevaluated 4171 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8417 times by 1 test
Evaluated by:
  • Self test
0-118577
5270 {-
5271 the_word->flags |= W_NOSPLIT;-
5272 if (parser_state & PST_COMPASSIGN)
parser_state & 0x002000Description
TRUEevaluated 4171 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115176 times by 1 test
Evaluated by:
  • Self test
4171-115176
5273 the_word->flags |= W_NOGLOB; /* XXX - W_NOBRACE? */
executed 4171 times by 1 test: the_word->flags |= 0x000020;
Executed by:
  • Self test
4171
5274 }
executed 119347 times by 1 test: end of block
Executed by:
  • Self test
119347
5275 }
executed 127764 times by 1 test: end of block
Executed by:
  • Self test
127764
5276-
5277 if (command_token_position (last_read_token))
((last_read_token) == 282)Description
TRUEevaluated 11944 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2443956 times by 1 test
Evaluated by:
  • Self test
(parser_state&0x080000)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2443948 times by 1 test
Evaluated by:
  • Self test
(last_read_tok...n == 299) == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_read_token == '<'Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == '>'Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 290Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 302Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 301Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 298Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 291Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 293Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 292Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 294Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
last_read_token == 299Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
(last_read_token) != 295Description
TRUEevaluated 2443941 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(last_read_token) != 296Description
TRUEevaluated 2443941 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(last_read_token) != 297Description
TRUEevaluated 2443941 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
reserved_word_...st_read_token)Description
TRUEevaluated 1214275 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1229666 times by 1 test
Evaluated by:
  • Self test
0-2443956
5278 {-
5279 struct builtin *b;-
5280 b = builtin_address_internal (token, 0);-
5281 if (b && (b->flags & ASSIGNMENT_BUILTIN))
bDescription
TRUEevaluated 869478 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 356749 times by 1 test
Evaluated by:
  • Self test
(b->flags & 0x10)Description
TRUEevaluated 4882 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 864596 times by 1 test
Evaluated by:
  • Self test
4882-869478
5282 parser_state |= PST_ASSIGNOK;
executed 4882 times by 1 test: parser_state |= 0x004000;
Executed by:
  • Self test
4882
5283 else if (STREQ (token, "eval") || STREQ (token, "let"))
never executed: __result = (((const unsigned char *) (const char *) ( token ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "eval" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( token ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
executed 2786 times by 1 test: __result = (((const unsigned char *) (const char *) ( "let" ))[3] - __s2[3]);
Executed by:
  • Self test
executed 2791 times by 1 test: end of block
Executed by:
  • Self test
executed 7674 times by 1 test: end of block
Executed by:
  • Self test
(token)[0] == ("eval")[0]Description
TRUEevaluated 757042 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 464303 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 6235 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 750807 times by 1 test
Evaluated by:
  • Self test
__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
(token)[0] == ("let")[0]Description
TRUEevaluated 7674 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1207436 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 2786 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4888 times by 1 test
Evaluated by:
  • Self test
__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
TRUEevaluated 7674 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 7674 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s2_len > 1Description
TRUEevaluated 7674 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 2791 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4883 times by 1 test
Evaluated by:
  • Self test
__s2_len > 2Description
TRUEevaluated 2791 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 2786 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-1207436
5284 parser_state |= PST_ASSIGNOK;
executed 9021 times by 1 test: parser_state |= 0x004000;
Executed by:
  • Self test
9021
5285 }
executed 1226227 times by 1 test: end of block
Executed by:
  • Self test
1226227
5286-
5287 yylval.word = the_word;-
5288-
5289 if (token[0] == '{' && token[token_index-1] == '}' &&
token[0] == '{'Description
TRUEevaluated 133 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2455767 times by 1 test
Evaluated by:
  • Self test
token[token_index-1] == '}'Description
TRUEevaluated 120 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
13-2455767
5290 (character == '<' || character == '>'))
character == '<'Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test
character == '>'Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
16-91
5291 {-
5292 /* can use token; already copied to the_word */-
5293 token[token_index-1] = '\0';-
5294#if defined (ARRAY_VARS)-
5295 if (legal_identifier (token+1) || valid_array_reference (token+1, 0))
legal_identifier (token+1)Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
valid_array_re...e (token+1, 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43
5296#else-
5297 if (legal_identifier (token+1))-
5298#endif-
5299 {-
5300 strcpy (the_word->word, token+1);-
5301/*itrace("read_token_word: returning REDIR_WORD for %s", the_word->word);*/-
5302 return (REDIR_WORD);
executed 45 times by 1 test: return (283);
Executed by:
  • Self test
45
5303 }-
5304 else-
5305 /* valid_array_reference can call the parser recursively; need to-
5306 make sure that yylval.word doesn't change if we are going to-
5307 return WORD or ASSIGNMENT_WORD */-
5308 yylval.word = the_word;
never executed: yylval.word = the_word;
0
5309 }-
5310-
5311 result = ((the_word->flags & (W_ASSIGNMENT|W_NOSPLIT)) == (W_ASSIGNMENT|W_NOSPLIT))
((the_word->fl...004|0x000010))Description
TRUEevaluated 119347 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2336508 times by 1 test
Evaluated by:
  • Self test
119347-2336508
5312 ? ASSIGNMENT_WORD : WORD;-
5313-
5314 switch (last_read_token)-
5315 {-
5316 case FUNCTION:
executed 29 times by 1 test: case 271:
Executed by:
  • Self test
29
5317 parser_state |= PST_ALLOWOPNBRC;-
5318 function_dstart = line_number;-
5319 break;
executed 29 times by 1 test: break;
Executed by:
  • Self test
29
5320 case CASE:
executed 78112 times by 1 test: case 263:
Executed by:
  • Self test
78112
5321 case SELECT:
executed 9 times by 1 test: case 266:
Executed by:
  • Self test
9
5322 case FOR:
executed 25658 times by 1 test: case 265:
Executed by:
  • Self test
25658
5323 if (word_top < MAX_CASE_NEST)
word_top < 128Description
TRUEevaluated 103708 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
71-103708
5324 word_top++;
executed 103708 times by 1 test: word_top++;
Executed by:
  • Self test
103708
5325 word_lineno[word_top] = line_number;-
5326 expecting_in_token++;-
5327 break;
executed 103779 times by 1 test: break;
Executed by:
  • Self test
103779
5328 }-
5329-
5330 return (result);
executed 2455855 times by 1 test: return (result);
Executed by:
  • Self test
2455855
5331}-
5332-
5333/* Return 1 if TOKSYM is a token that after being read would allow-
5334 a reserved word to be seen, else 0. */-
5335static int-
5336reserved_word_acceptable (toksym)-
5337 int toksym;-
5338{-
5339 switch (toksym)-
5340 {-
5341 case '\n':
executed 2550517 times by 1 test: case '\n':
Executed by:
  • Self test
2550517
5342 case ';':
executed 114724 times by 1 test: case ';':
Executed by:
  • Self test
114724
5343 case '(':
executed 18447 times by 1 test: case '(':
Executed by:
  • Self test
18447
5344 case ')':
executed 342776 times by 1 test: case ')':
Executed by:
  • Self test
342776
5345 case '|':
executed 34089 times by 1 test: case '|':
Executed by:
  • Self test
34089
5346 case '&':
executed 250 times by 1 test: case '&':
Executed by:
  • Self test
250
5347 case '{':
executed 12700 times by 1 test: case '{':
Executed by:
  • Self test
12700
5348 case '}': /* XXX */
never executed: case '}':
0
5349 case AND_AND:
executed 1762 times by 1 test: case 288:
Executed by:
  • Self test
1762
5350 case BANG:
executed 463 times by 1 test: case 277:
Executed by:
  • Self test
463
5351 case BAR_AND:
executed 6 times by 1 test: case 303:
Executed by:
  • Self test
6
5352 case DO:
executed 14759 times by 1 test: case 269:
Executed by:
  • Self test
14759
5353 case DONE:
executed 26 times by 1 test: case 270:
Executed by:
  • Self test
26
5354 case ELIF:
executed 229 times by 1 test: case 261:
Executed by:
  • Self test
229
5355 case ELSE:
executed 72 times by 1 test: case 260:
Executed by:
  • Self test
72
5356 case ESAC:
executed 4 times by 1 test: case 264:
Executed by:
  • Self test
4
5357 case FI:
never executed: case 262:
0
5358 case IF:
executed 2481 times by 1 test: case 258:
Executed by:
  • Self test
2481
5359 case OR_OR:
executed 44405 times by 1 test: case 289:
Executed by:
  • Self test
44405
5360 case SEMI_SEMI:
executed 114 times by 1 test: case 295:
Executed by:
  • Self test
114
5361 case SEMI_AND:
never executed: case 296:
0
5362 case SEMI_SEMI_AND:
never executed: case 297:
0
5363 case THEN:
executed 151 times by 1 test: case 259:
Executed by:
  • Self test
151
5364 case TIME:
executed 14 times by 1 test: case 278:
Executed by:
  • Self test
14
5365 case TIMEOPT:
executed 18 times by 1 test: case 279:
Executed by:
  • Self test
18
5366 case TIMEIGN:
executed 2 times by 1 test: case 280:
Executed by:
  • Self test
2
5367 case COPROC:
executed 70 times by 1 test: case 272:
Executed by:
  • Self test
70
5368 case UNTIL:
executed 29 times by 1 test: case 268:
Executed by:
  • Self test
29
5369 case WHILE:
executed 15370 times by 1 test: case 267:
Executed by:
  • Self test
15370
5370 case 0:
executed 2547 times by 1 test: case 0:
Executed by:
  • Self test
2547
5371 return 1;
executed 3156025 times by 1 test: return 1;
Executed by:
  • Self test
3156025
5372 default:
executed 2257863 times by 1 test: default:
Executed by:
  • Self test
2257863
5373#if defined (COPROCESS_SUPPORT)-
5374 if (last_read_token == WORD && token_before_that == COPROC)
last_read_token == 281Description
TRUEevaluated 1994064 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 263799 times by 1 test
Evaluated by:
  • Self test
token_before_that == 272Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1994029 times by 1 test
Evaluated by:
  • Self test
35-1994064
5375 return 1;
executed 35 times by 1 test: return 1;
Executed by:
  • Self test
35
5376#endif-
5377 if (last_read_token == WORD && token_before_that == FUNCTION)
last_read_token == 281Description
TRUEevaluated 1994029 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 263799 times by 1 test
Evaluated by:
  • Self test
token_before_that == 271Description
TRUEnever evaluated
FALSEevaluated 1994029 times by 1 test
Evaluated by:
  • Self test
0-1994029
5378 return 1;
never executed: return 1;
0
5379 return 0;
executed 2257828 times by 1 test: return 0;
Executed by:
  • Self test
2257828
5380 }-
5381}-
5382 -
5383/* Return the index of TOKEN in the alist of reserved words, or -1 if-
5384 TOKEN is not a shell reserved word. */-
5385int-
5386find_reserved_word (tokstr)-
5387 char *tokstr;-
5388{-
5389 int i;-
5390 for (i = 0; word_token_alist[i].word; i++)
word_token_alist[i].wordDescription
TRUEevaluated 14488 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 654 times by 1 test
Evaluated by:
  • Self test
654-14488
5391 if (STREQ (tokstr, word_token_alist[i].word))
never executed: __result = (((const unsigned char *) (const char *) ( tokstr ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( word_token_alist[i].word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(tokstr)[0] ==...st[i].word)[0]Description
TRUEevaluated 1672 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12816 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1662 times by 1 test
Evaluated by:
  • Self test
__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-12816
5392 return i;
executed 10 times by 1 test: return i;
Executed by:
  • Self test
10
5393 return -1;
executed 654 times by 1 test: return -1;
Executed by:
  • Self test
654
5394}-
5395-
5396/* An interface to let the rest of the shell (primarily the completion-
5397 system) know what the parser is expecting. */-
5398int-
5399parser_in_command_position ()-
5400{-
5401 return (command_token_position (last_read_token));
never executed: return ((((last_read_token) == 282) || ((parser_state&0x080000) && (last_read_token == '<' || last_read_token == '>' || last_read_token == 290 || last_read_token == 302 || last_read_token == 301 || last_read_token == 298 || last_read_token == 291 || last_read_token == 293 || last_read_token == 292 || last_read_token == 294 || last_read_token == 299) == 0) || ((last_read_token) != 295 && (last_read_token) != 296 && (last_read_token) != 297 && reserved_word_acceptable(last_read_token))));
0
5402}-
5403-
5404#if 0-
5405#if defined (READLINE)-
5406/* Called after each time readline is called. This insures that whatever-
5407 the new prompt string is gets propagated to readline's local prompt-
5408 variable. */-
5409static void-
5410reset_readline_prompt ()-
5411{-
5412 char *temp_prompt;-
5413-
5414 if (prompt_string_pointer)-
5415 {-
5416 temp_prompt = (*prompt_string_pointer)-
5417 ? decode_prompt_string (*prompt_string_pointer)-
5418 : (char *)NULL;-
5419-
5420 if (temp_prompt == 0)-
5421 {-
5422 temp_prompt = (char *)xmalloc (1);-
5423 temp_prompt[0] = '\0';-
5424 }-
5425-
5426 FREE (current_readline_prompt);-
5427 current_readline_prompt = temp_prompt;-
5428 }-
5429}-
5430#endif /* READLINE */-
5431#endif /* 0 */-
5432-
5433#if defined (HISTORY)-
5434/* A list of tokens which can be followed by newlines, but not by-
5435 semi-colons. When concatenating multiple lines of history, the-
5436 newline separator for such tokens is replaced with a space. */-
5437static const int no_semi_successors[] = {-
5438 '\n', '{', '(', ')', ';', '&', '|',-
5439 CASE, DO, ELSE, IF, SEMI_SEMI, SEMI_AND, SEMI_SEMI_AND, THEN, UNTIL,-
5440 WHILE, AND_AND, OR_OR, IN,-
5441 0-
5442};-
5443-
5444/* If we are not within a delimited expression, try to be smart-
5445 about which separators can be semi-colons and which must be-
5446 newlines. Returns the string that should be added into the-
5447 history entry. LINE is the line we're about to add; it helps-
5448 make some more intelligent decisions in certain cases. */-
5449char *-
5450history_delimiting_chars (line)-
5451 const char *line;-
5452{-
5453 static int last_was_heredoc = 0; /* was the last entry the start of a here document? */-
5454 register int i;-
5455-
5456 if ((parser_state & PST_HEREDOC) == 0)
(parser_state & 0x020000) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-5
5457 last_was_heredoc = 0;
executed 5 times by 1 test: last_was_heredoc = 0;
Executed by:
  • Self test
5
5458-
5459 if (dstack.delimiter_depth != 0)
dstack.delimiter_depth != 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
5460 return ("\n");
never executed: return ("\n");
0
5461-
5462 /* We look for current_command_line_count == 2 because we are looking to-
5463 add the first line of the body of the here document (the second line-
5464 of the command). We also keep LAST_WAS_HEREDOC as a private sentinel-
5465 variable to note when we think we added the first line of a here doc-
5466 (the one with a "<<" somewhere in it) */-
5467 if (parser_state & PST_HEREDOC)
parser_state & 0x020000Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
4-5
5468 {-
5469 if (last_was_heredoc)
last_was_heredocDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-4
5470 {-
5471 last_was_heredoc = 0;-
5472 return "\n";
never executed: return "\n";
0
5473 }-
5474 return (here_doc_first_line ? "\n" : "");
executed 4 times by 1 test: return (here_doc_first_line ? "\n" : "");
Executed by:
  • Self test
4
5475 }-
5476-
5477 if (parser_state & PST_COMPASSIGN)
parser_state & 0x002000Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
5478 return (" ");
never executed: return (" ");
0
5479-
5480 /* First, handle some special cases. */-
5481 /*(*/-
5482 /* If we just read `()', assume it's a function definition, and don't-
5483 add a semicolon. If the token before the `)' was not `(', and we're-
5484 not in the midst of parsing a case statement, assume it's a-
5485 parenthesized command and add the semicolon. */-
5486 /*)(*/-
5487 if (token_before_that == ')')
token_before_that == ')'Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
5488 {-
5489 if (two_tokens_ago == '(') /*)*/ /* function def */
two_tokens_ago == '('Description
TRUEnever evaluated
FALSEnever evaluated
0
5490 return " ";
never executed: return " ";
0
5491 /* This does not work for subshells inside case statement-
5492 command lists. It's a suboptimal solution. */-
5493 else if (parser_state & PST_CASESTMT) /* case statement pattern */
parser_state & 0x000080Description
TRUEnever evaluated
FALSEnever evaluated
0
5494 return " ";
never executed: return " ";
0
5495 else-
5496 return "; "; /* (...) subshell */
never executed: return "; ";
0
5497 }-
5498 else if (token_before_that == WORD && two_tokens_ago == FUNCTION)
token_before_that == 281Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
two_tokens_ago == 271Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-3
5499 return " "; /* function def using `function name' without `()' */
never executed: return " ";
0
5500-
5501 /* If we're not in a here document, but we think we're about to parse one,-
5502 and we would otherwise return a `;', return a newline to delimit the-
5503 line with the here-doc delimiter */-
5504 else if ((parser_state & PST_HEREDOC) == 0 && current_command_line_count > 1 && last_read_token == '\n' && strstr (line, "<<"))
(parser_state & 0x020000) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
current_command_line_count > 1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_read_token == '\n'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strstr (line, "<<")Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
5505 {-
5506 last_was_heredoc = 1;-
5507 return "\n";
never executed: return "\n";
0
5508 }-
5509 else if ((parser_state & PST_HEREDOC) == 0 && current_command_line_count > 1 && need_here_doc > 0)
(parser_state & 0x020000) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
current_command_line_count > 1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
need_here_doc > 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
5510 return "\n";
never executed: return "\n";
0
5511 else if (token_before_that == WORD && two_tokens_ago == FOR)
token_before_that == 281Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
two_tokens_ago == 265Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-3
5512 {-
5513 /* Tricky. `for i\nin ...' should not have a semicolon, but-
5514 `for i\ndo ...' should. We do what we can. */-
5515 for (i = shell_input_line_index; whitespace (shell_input_line[i]); i++)
((shell_input_line[i]) == ' ')Description
TRUEnever evaluated
FALSEnever evaluated
((shell_input_...e[i]) == '\t')Description
TRUEnever evaluated
FALSEnever evaluated
0
5516 ;
never executed: ;
0
5517 if (shell_input_line[i] && shell_input_line[i] == 'i' && shell_input_line[i+1] == 'n')
shell_input_line[i]Description
TRUEnever evaluated
FALSEnever evaluated
shell_input_line[i] == 'i'Description
TRUEnever evaluated
FALSEnever evaluated
shell_input_line[i+1] == 'n'Description
TRUEnever evaluated
FALSEnever evaluated
0
5518 return " ";
never executed: return " ";
0
5519 return ";";
never executed: return ";";
0
5520 }-
5521 else if (two_tokens_ago == CASE && token_before_that == WORD && (parser_state & PST_CASESTMT))
two_tokens_ago == 263Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
token_before_that == 281Description
TRUEnever evaluated
FALSEnever evaluated
(parser_state & 0x000080)Description
TRUEnever evaluated
FALSEnever evaluated
0-5
5522 return " ";
never executed: return " ";
0
5523-
5524 for (i = 0; no_semi_successors[i]; i++)
no_semi_successors[i]Description
TRUEevaluated 81 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-81
5525 {-
5526 if (token_before_that == no_semi_successors[i])
token_before_t..._successors[i]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78 times by 1 test
Evaluated by:
  • Self test
3-78
5527 return (" ");
executed 3 times by 1 test: return (" ");
Executed by:
  • Self test
3
5528 }
executed 78 times by 1 test: end of block
Executed by:
  • Self test
78
5529-
5530 if (line_isblank (line))
line_isblank (line)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
5531 return ("");
never executed: return ("");
0
5532-
5533 return ("; ");
executed 2 times by 1 test: return ("; ");
Executed by:
  • Self test
2
5534}-
5535#endif /* HISTORY */-
5536-
5537/* Issue a prompt, or prepare to issue a prompt when the next character-
5538 is read. */-
5539static void-
5540prompt_again ()-
5541{-
5542 char *temp_prompt;-
5543-
5544 if (interactive == 0 || expanding_alias ()) /* XXX */
interactive == 0Description
TRUEnever evaluated
FALSEnever evaluated
pushed_string_listDescription
TRUEnever evaluated
FALSEnever evaluated
pushed_string_list->expanderDescription
TRUEnever evaluated
FALSEnever evaluated
0
5545 return;
never executed: return;
0
5546-
5547 ps1_prompt = get_string_value ("PS1");-
5548 ps2_prompt = get_string_value ("PS2");-
5549-
5550 ps0_prompt = get_string_value ("PS0");-
5551-
5552 if (!prompt_string_pointer)
!prompt_string_pointerDescription
TRUEnever evaluated
FALSEnever evaluated
0
5553 prompt_string_pointer = &ps1_prompt;
never executed: prompt_string_pointer = &ps1_prompt;
0
5554-
5555 temp_prompt = *prompt_string_pointer
*prompt_string_pointerDescription
TRUEnever evaluated
FALSEnever evaluated
0
5556 ? decode_prompt_string (*prompt_string_pointer)-
5557 : (char *)NULL;-
5558-
5559 if (temp_prompt == 0)
temp_prompt == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5560 {-
5561 temp_prompt = (char *)xmalloc (1);-
5562 temp_prompt[0] = '\0';-
5563 }
never executed: end of block
0
5564-
5565 current_prompt_string = *prompt_string_pointer;-
5566 prompt_string_pointer = &ps2_prompt;-
5567-
5568#if defined (READLINE)-
5569 if (!no_line_editing)
!no_line_editingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5570 {-
5571 FREE (current_readline_prompt);
never executed: sh_xfree((current_readline_prompt), "./parse.y", 5571);
current_readline_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
5572 current_readline_prompt = temp_prompt;-
5573 }
never executed: end of block
0
5574 else-
5575#endif /* READLINE */-
5576 {-
5577 FREE (current_decoded_prompt);
never executed: sh_xfree((current_decoded_prompt), "./parse.y", 5577);
current_decoded_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
5578 current_decoded_prompt = temp_prompt;-
5579 }
never executed: end of block
0
5580}-
5581-
5582int-
5583get_current_prompt_level ()-
5584{-
5585 return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
executed 17 times by 1 test: return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
Executed by:
  • Self test
17
5586}-
5587-
5588void-
5589set_current_prompt_level (x)-
5590 int x;-
5591{-
5592 prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt;
(x == 2)Description
TRUEnever evaluated
FALSEevaluated 176420 times by 1 test
Evaluated by:
  • Self test
0-176420
5593 current_prompt_string = *prompt_string_pointer;-
5594}
executed 176420 times by 1 test: end of block
Executed by:
  • Self test
176420
5595 -
5596static void-
5597print_prompt ()-
5598{-
5599 fprintf (stderr, "%s", current_decoded_prompt);-
5600 fflush (stderr);-
5601}
never executed: end of block
0
5602-
5603#if defined (HISTORY)-
5604 /* The history library increments the history offset as soon as it stores-
5605 the first line of a potentially multi-line command, so we compensate-
5606 here by returning one fewer when appropriate. */-
5607static int-
5608prompt_history_number (pmt)-
5609 char *pmt;-
5610{-
5611 int ret;-
5612-
5613 ret = history_number ();-
5614 if (ret == 1)
ret == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
5615 return ret;
never executed: return ret;
0
5616-
5617 if (pmt == ps1_prompt) /* are we expanding $PS1? */
pmt == ps1_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
5618 return ret;
never executed: return ret;
0
5619 else if (pmt == ps2_prompt && command_oriented_history == 0)
pmt == ps2_promptDescription
TRUEnever evaluated
FALSEnever evaluated
command_oriented_history == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5620 return ret; /* not command oriented history */
never executed: return ret;
0
5621 else if (pmt == ps2_prompt && command_oriented_history && current_command_first_line_saved)
pmt == ps2_promptDescription
TRUEnever evaluated
FALSEnever evaluated
command_oriented_historyDescription
TRUEnever evaluated
FALSEnever evaluated
current_comman...rst_line_savedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5622 return ret - 1;
never executed: return ret - 1;
0
5623 else-
5624 return ret - 1; /* PS0, PS4, ${var@P}, PS2 other cases */
never executed: return ret - 1;
0
5625}-
5626#endif-
5627-
5628/* Return a string which will be printed as a prompt. The string-
5629 may contain special characters which are decoded as follows:-
5630-
5631 \a bell (ascii 07)-
5632 \d the date in Day Mon Date format-
5633 \e escape (ascii 033)-
5634 \h the hostname up to the first `.'-
5635 \H the hostname-
5636 \j the number of active jobs-
5637 \l the basename of the shell's tty device name-
5638 \n CRLF-
5639 \r CR-
5640 \s the name of the shell-
5641 \t the time in 24-hour hh:mm:ss format-
5642 \T the time in 12-hour hh:mm:ss format-
5643 \@ the time in 12-hour hh:mm am/pm format-
5644 \A the time in 24-hour hh:mm format-
5645 \D{fmt} the result of passing FMT to strftime(3)-
5646 \u your username-
5647 \v the version of bash (e.g., 2.00)-
5648 \V the release of bash, version + patchlevel (e.g., 2.00.0)-
5649 \w the current working directory-
5650 \W the last element of $PWD-
5651 \! the history number of this command-
5652 \# the command number of this command-
5653 \$ a $ or a # if you are root-
5654 \nnn character code nnn in octal-
5655 \\ a backslash-
5656 \[ begin a sequence of non-printing chars-
5657 \] end a sequence of non-printing chars-
5658*/-
5659#define PROMPT_GROWTH 48-
5660char *-
5661decode_prompt_string (string)-
5662 char *string;-
5663{-
5664 WORD_LIST *list;-
5665 char *result, *t, *orig_string;-
5666 struct dstack save_dstack;-
5667 int last_exit_value, last_comsub_pid;-
5668#if defined (PROMPT_STRING_DECODE)-
5669 size_t result_size;-
5670 int result_index;-
5671 int c, n, i;-
5672 char *temp, *t_host, octal_string[4];-
5673 struct tm *tm; -
5674 time_t the_time;-
5675 char timebuf[128];-
5676 char *timefmt;-
5677-
5678 result = (char *)xmalloc (result_size = PROMPT_GROWTH);-
5679 result[result_index = 0] = 0;-
5680 temp = (char *)NULL;-
5681 orig_string = string;-
5682-
5683 while (c = *string++)
c = *string++Description
TRUEevaluated 241 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
61-241
5684 {-
5685 if (posixly_correct && c == '!')
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 241 times by 1 test
Evaluated by:
  • Self test
c == '!'Description
TRUEnever evaluated
FALSEnever evaluated
0-241
5686 {-
5687 if (*string == '!')
*string == '!'Description
TRUEnever evaluated
FALSEnever evaluated
0
5688 {-
5689 temp = savestring ("!");-
5690 goto add_string;
never executed: goto add_string;
0
5691 }-
5692 else-
5693 {-
5694#if !defined (HISTORY)-
5695 temp = savestring ("1");-
5696#else /* HISTORY */-
5697 temp = itos (prompt_history_number (orig_string));-
5698#endif /* HISTORY */-
5699 string--; /* add_string increments string again. */-
5700 goto add_string;
never executed: goto add_string;
0
5701 }-
5702 }-
5703 if (c == '\\')
c == '\\'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 237 times by 1 test
Evaluated by:
  • Self test
4-237
5704 {-
5705 c = *string;-
5706-
5707 switch (c)-
5708 {-
5709 case '0':
never executed: case '0':
0
5710 case '1':
never executed: case '1':
0
5711 case '2':
never executed: case '2':
0
5712 case '3':
never executed: case '3':
0
5713 case '4':
never executed: case '4':
0
5714 case '5':
never executed: case '5':
0
5715 case '6':
never executed: case '6':
0
5716 case '7':
never executed: case '7':
0
5717 strncpy (octal_string, string, 3);-
5718 octal_string[3] = '\0';-
5719-
5720 n = read_octal (octal_string);-
5721 temp = (char *)xmalloc (3);-
5722-
5723 if (n == CTLESC || n == CTLNUL)
n == '\001'Description
TRUEnever evaluated
FALSEnever evaluated
n == '\177'Description
TRUEnever evaluated
FALSEnever evaluated
0
5724 {-
5725 temp[0] = CTLESC;-
5726 temp[1] = n;-
5727 temp[2] = '\0';-
5728 }
never executed: end of block
0
5729 else if (n == -1)
n == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5730 {-
5731 temp[0] = '\\';-
5732 temp[1] = '\0';-
5733 }
never executed: end of block
0
5734 else-
5735 {-
5736 temp[0] = n;-
5737 temp[1] = '\0';-
5738 }
never executed: end of block
0
5739-
5740 for (c = 0; n != -1 && c < 3 && ISOCTAL (*string); c++)
n != -1Description
TRUEnever evaluated
FALSEnever evaluated
c < 3Description
TRUEnever evaluated
FALSEnever evaluated
(*string) >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
(*string) <= '7'Description
TRUEnever evaluated
FALSEnever evaluated
0
5741 string++;
never executed: string++;
0
5742-
5743 c = 0; /* tested at add_string: */-
5744 goto add_string;
never executed: goto add_string;
0
5745-
5746 case 'd':
never executed: case 'd':
0
5747 case 't':
never executed: case 't':
0
5748 case 'T':
never executed: case 'T':
0
5749 case '@':
never executed: case '@':
0
5750 case 'A':
never executed: case 'A':
0
5751 /* Make the current time/date into a string. */-
5752 (void) time (&the_time);-
5753#if defined (HAVE_TZSET)-
5754 sv_tz ("TZ"); /* XXX -- just make sure */-
5755#endif-
5756 tm = localtime (&the_time);-
5757-
5758 if (c == 'd')
c == 'd'Description
TRUEnever evaluated
FALSEnever evaluated
0
5759 n = strftime (timebuf, sizeof (timebuf), "%a %b %d", tm);
never executed: n = strftime (timebuf, sizeof (timebuf), "%a %b %d", tm);
0
5760 else if (c == 't')
c == 't'Description
TRUEnever evaluated
FALSEnever evaluated
0
5761 n = strftime (timebuf, sizeof (timebuf), "%H:%M:%S", tm);
never executed: n = strftime (timebuf, sizeof (timebuf), "%H:%M:%S", tm);
0
5762 else if (c == 'T')
c == 'T'Description
TRUEnever evaluated
FALSEnever evaluated
0
5763 n = strftime (timebuf, sizeof (timebuf), "%I:%M:%S", tm);
never executed: n = strftime (timebuf, sizeof (timebuf), "%I:%M:%S", tm);
0
5764 else if (c == '@')
c == '@'Description
TRUEnever evaluated
FALSEnever evaluated
0
5765 n = strftime (timebuf, sizeof (timebuf), "%I:%M %p", tm);
never executed: n = strftime (timebuf, sizeof (timebuf), "%I:%M %p", tm);
0
5766 else if (c == 'A')
c == 'A'Description
TRUEnever evaluated
FALSEnever evaluated
0
5767 n = strftime (timebuf, sizeof (timebuf), "%H:%M", tm);
never executed: n = strftime (timebuf, sizeof (timebuf), "%H:%M", tm);
0
5768-
5769 if (n == 0)
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5770 timebuf[0] = '\0';
never executed: timebuf[0] = '\0';
0
5771 else-
5772 timebuf[sizeof(timebuf) - 1] = '\0';
never executed: timebuf[sizeof(timebuf) - 1] = '\0';
0
5773-
5774 temp = savestring (timebuf);-
5775 goto add_string;
never executed: goto add_string;
0
5776-
5777 case 'D': /* strftime format */
never executed: case 'D':
0
5778 if (string[1] != '{') /* } */
string[1] != '{'Description
TRUEnever evaluated
FALSEnever evaluated
0
5779 goto not_escape;
never executed: goto not_escape;
0
5780-
5781 (void) time (&the_time);-
5782 tm = localtime (&the_time);-
5783 string += 2; /* skip { */-
5784 timefmt = xmalloc (strlen (string) + 3);-
5785 for (t = timefmt; *string && *string != '}'; )
*stringDescription
TRUEnever evaluated
FALSEnever evaluated
*string != '}'Description
TRUEnever evaluated
FALSEnever evaluated
0
5786 *t++ = *string++;
never executed: *t++ = *string++;
0
5787 *t = '\0';-
5788 c = *string; /* tested at add_string */-
5789 if (timefmt[0] == '\0')
timefmt[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
5790 {-
5791 timefmt[0] = '%';-
5792 timefmt[1] = 'X'; /* locale-specific current time */-
5793 timefmt[2] = '\0';-
5794 }
never executed: end of block
0
5795 n = strftime (timebuf, sizeof (timebuf), timefmt, tm);-
5796 free (timefmt);-
5797-
5798 if (n == 0)
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5799 timebuf[0] = '\0';
never executed: timebuf[0] = '\0';
0
5800 else-
5801 timebuf[sizeof(timebuf) - 1] = '\0';
never executed: timebuf[sizeof(timebuf) - 1] = '\0';
0
5802-
5803 if (promptvars || posixly_correct)
promptvarsDescription
TRUEnever evaluated
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0
5804 /* Make sure that expand_prompt_string is called with a-
5805 second argument of Q_DOUBLE_QUOTES if we use this-
5806 function here. */-
5807 temp = sh_backslash_quote_for_double_quotes (timebuf);
never executed: temp = sh_backslash_quote_for_double_quotes (timebuf);
0
5808 else-
5809 temp = savestring (timebuf);
never executed: temp = (char *)strcpy (sh_xmalloc((1 + strlen (timebuf)), "./parse.y", 5809), (timebuf));
0
5810 goto add_string;
never executed: goto add_string;
0
5811 -
5812 case 'n':
never executed: case 'n':
0
5813 temp = (char *)xmalloc (3);-
5814 temp[0] = no_line_editing ? '\n' : '\r';
no_line_editingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5815 temp[1] = no_line_editing ? '\0' : '\n';
no_line_editingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5816 temp[2] = '\0';-
5817 goto add_string;
never executed: goto add_string;
0
5818-
5819 case 's':
never executed: case 's':
0
5820 temp = base_pathname (shell_name);-
5821 /* Try to quote anything the user can set in the file system */-
5822 if (promptvars || posixly_correct)
promptvarsDescription
TRUEnever evaluated
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0
5823 temp = sh_backslash_quote_for_double_quotes (temp);
never executed: temp = sh_backslash_quote_for_double_quotes (temp);
0
5824 else-
5825 temp = savestring (temp);
never executed: temp = (char *)strcpy (sh_xmalloc((1 + strlen (temp)), "./parse.y", 5825), (temp));
0
5826 goto add_string;
never executed: goto add_string;
0
5827-
5828 case 'v':
executed 1 time by 1 test: case 'v':
Executed by:
  • Self test
1
5829 case 'V':
never executed: case 'V':
0
5830 temp = (char *)xmalloc (16);-
5831 if (c == 'v')
c == 'v'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
5832 strcpy (temp, dist_version);
executed 1 time by 1 test: strcpy (temp, dist_version);
Executed by:
  • Self test
1
5833 else-
5834 sprintf (temp, "%s.%d", dist_version, patch_level);
never executed: sprintf (temp, "%s.%d", dist_version, patch_level);
0
5835 goto add_string;
executed 1 time by 1 test: goto add_string;
Executed by:
  • Self test
1
5836-
5837 case 'w':
never executed: case 'w':
0
5838 case 'W':
never executed: case 'W':
0
5839 {-
5840 /* Use the value of PWD because it is much more efficient. */-
5841 char t_string[PATH_MAX];-
5842 int tlen;-
5843-
5844 temp = get_string_value ("PWD");-
5845-
5846 if (temp == 0)
temp == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5847 {-
5848 if (getcwd (t_string, sizeof(t_string)) == 0)
getcwd (t_stri..._string)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5849 {-
5850 t_string[0] = '.';-
5851 tlen = 1;-
5852 }
never executed: end of block
0
5853 else-
5854 tlen = strlen (t_string);
never executed: tlen = strlen (t_string);
0
5855 }-
5856 else-
5857 {-
5858 tlen = sizeof (t_string) - 1;-
5859 strncpy (t_string, temp, tlen);-
5860 }
never executed: end of block
0
5861 t_string[tlen] = '\0';-
5862-
5863#if defined (MACOSX)-
5864 /* Convert from "fs" format to "input" format */-
5865 temp = fnx_fromfs (t_string, strlen (t_string));-
5866 if (temp != t_string)-
5867 strcpy (t_string, temp);-
5868#endif-
5869-
5870#define ROOT_PATH(x) ((x)[0] == '/' && (x)[1] == 0)-
5871#define DOUBLE_SLASH_ROOT(x) ((x)[0] == '/' && (x)[1] == '/' && (x)[2] == 0)-
5872 /* Abbreviate \W as ~ if $PWD == $HOME */-
5873 if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, t_string) == 0))
never executed: __result = (((const unsigned char *) (const char *) ( t ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( t_string ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
c == 'W'Description
TRUEnever evaluated
FALSEnever evaluated
((t = get_stri..."HOME")) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((t)[0] == (t_... }) == 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(t)[0] == (t_string)[0]Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
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
5874 {-
5875 if (ROOT_PATH (t_string) == 0 && DOUBLE_SLASH_ROOT (t_string) == 0)
((t_string)[0]...[1] == 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(t_string)[0] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
(t_string)[1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
((t_string)[0]...[2] == 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(t_string)[0] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
(t_string)[1] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
(t_string)[2] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5876 {-
5877 t = strrchr (t_string, '/');-
5878 if (t)
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
5879 memmove (t_string, t + 1, strlen (t)); /* strlen(t) to copy NULL */
never executed: memmove (t_string, t + 1, strlen (t));
0
5880 }
never executed: end of block
0
5881 }
never executed: end of block
0
5882#undef ROOT_PATH-
5883#undef DOUBLE_SLASH_ROOT-
5884 else-
5885 {-
5886 /* polite_directory_format is guaranteed to return a string-
5887 no longer than PATH_MAX - 1 characters. */-
5888 temp = polite_directory_format (t_string);-
5889 if (temp != t_string)
temp != t_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
5890 strcpy (t_string, temp);
never executed: strcpy (t_string, temp);
0
5891 }
never executed: end of block
0
5892-
5893 temp = trim_pathname (t_string, PATH_MAX - 1);-
5894 /* If we're going to be expanding the prompt string later,-
5895 quote the directory name. */-
5896 if (promptvars || posixly_correct)
promptvarsDescription
TRUEnever evaluated
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0
5897 /* Make sure that expand_prompt_string is called with a-
5898 second argument of Q_DOUBLE_QUOTES if we use this-
5899 function here. */-
5900 temp = sh_backslash_quote_for_double_quotes (t_string);
never executed: temp = sh_backslash_quote_for_double_quotes (t_string);
0
5901 else-
5902 temp = savestring (t_string);
never executed: temp = (char *)strcpy (sh_xmalloc((1 + strlen (t_string)), "./parse.y", 5902), (t_string));
0
5903-
5904 goto add_string;
never executed: goto add_string;
0
5905 }-
5906-
5907 case 'u':
never executed: case 'u':
0
5908 if (current_user.user_name == 0)
current_user.user_name == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5909 get_current_user_info ();
never executed: get_current_user_info ();
0
5910 temp = savestring (current_user.user_name);-
5911 goto add_string;
never executed: goto add_string;
0
5912-
5913 case 'h':
never executed: case 'h':
0
5914 case 'H':
never executed: case 'H':
0
5915 t_host = savestring (current_host_name);-
5916 if (c == 'h' && (t = (char *)strchr (t_host, '.')))
c == 'h'Description
TRUEnever evaluated
FALSEnever evaluated
(t = (char *) ...st , '.' ))) )Description
TRUEnever evaluated
FALSEnever evaluated
0
5917 *t = '\0';
never executed: *t = '\0';
0
5918 if (promptvars || posixly_correct)
promptvarsDescription
TRUEnever evaluated
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0
5919 /* Make sure that expand_prompt_string is called with a-
5920 second argument of Q_DOUBLE_QUOTES if we use this-
5921 function here. */-
5922 temp = sh_backslash_quote_for_double_quotes (t_host);
never executed: temp = sh_backslash_quote_for_double_quotes (t_host);
0
5923 else-
5924 temp = savestring (t_host);
never executed: temp = (char *)strcpy (sh_xmalloc((1 + strlen (t_host)), "./parse.y", 5924), (t_host));
0
5925 free (t_host);-
5926 goto add_string;
never executed: goto add_string;
0
5927-
5928 case '#':
never executed: case '#':
0
5929 n = current_command_number;-
5930 /* If we have already incremented current_command_number (PS4,-
5931 ${var@P}), compensate */-
5932 if (orig_string != ps0_prompt && orig_string != ps1_prompt && orig_string != ps2_prompt)
orig_string != ps0_promptDescription
TRUEnever evaluated
FALSEnever evaluated
orig_string != ps1_promptDescription
TRUEnever evaluated
FALSEnever evaluated
orig_string != ps2_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
5933 n--;
never executed: n--;
0
5934 temp = itos (n);-
5935 goto add_string;
never executed: goto add_string;
0
5936-
5937 case '!':
never executed: case '!':
0
5938#if !defined (HISTORY)-
5939 temp = savestring ("1");-
5940#else /* HISTORY */-
5941 temp = itos (prompt_history_number (orig_string));-
5942#endif /* HISTORY */-
5943 goto add_string;
never executed: goto add_string;
0
5944-
5945 case '$':
executed 1 time by 1 test: case '$':
Executed by:
  • Self test
1
5946 t = temp = (char *)xmalloc (3);-
5947 if ((promptvars || posixly_correct) && (current_user.euid != 0))
promptvarsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
(current_user.euid != 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
5948 *t++ = '\\';
executed 1 time by 1 test: *t++ = '\\';
Executed by:
  • Self test
1
5949 *t++ = current_user.euid == 0 ? '#' : '$';
current_user.euid == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
5950 *t = '\0';-
5951 goto add_string;
executed 1 time by 1 test: goto add_string;
Executed by:
  • Self test
1
5952-
5953 case 'j':
never executed: case 'j':
0
5954 temp = itos (count_all_jobs ());-
5955 goto add_string;
never executed: goto add_string;
0
5956-
5957 case 'l':
never executed: case 'l':
0
5958#if defined (HAVE_TTYNAME)-
5959 temp = (char *)ttyname (fileno (stdin));-
5960 t = temp ? base_pathname (temp) : "tty";
tempDescription
TRUEnever evaluated
FALSEnever evaluated
0
5961 temp = savestring (t);-
5962#else-
5963 temp = savestring ("tty");-
5964#endif /* !HAVE_TTYNAME */-
5965 goto add_string;
never executed: goto add_string;
0
5966-
5967#if defined (READLINE)-
5968 case '[':
executed 1 time by 1 test: case '[':
Executed by:
  • Self test
1
5969 case ']':
executed 1 time by 1 test: case ']':
Executed by:
  • Self test
1
5970 if (no_line_editing)
no_line_editingDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
5971 {-
5972 string++;-
5973 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
5974 }-
5975 temp = (char *)xmalloc (3);-
5976 n = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
(c == '[')Description
TRUEnever evaluated
FALSEnever evaluated
0
5977 i = 0;-
5978 if (n == CTLESC || n == CTLNUL)
n == '\001'Description
TRUEnever evaluated
FALSEnever evaluated
n == '\177'Description
TRUEnever evaluated
FALSEnever evaluated
0
5979 temp[i++] = CTLESC;
never executed: temp[i++] = '\001';
0
5980 temp[i++] = n;-
5981 temp[i] = '\0';-
5982 goto add_string;
never executed: goto add_string;
0
5983#endif /* READLINE */-
5984-
5985 case '\\':
never executed: case '\\':
0
5986 case 'a':
never executed: case 'a':
0
5987 case 'e':
never executed: case 'e':
0
5988 case 'r':
never executed: case 'r':
0
5989 temp = (char *)xmalloc (2);-
5990 if (c == 'a')
c == 'a'Description
TRUEnever evaluated
FALSEnever evaluated
0
5991 temp[0] = '\07';
never executed: temp[0] = '\07';
0
5992 else if (c == 'e')
c == 'e'Description
TRUEnever evaluated
FALSEnever evaluated
0
5993 temp[0] = '\033';
never executed: temp[0] = '\033';
0
5994 else if (c == 'r')
c == 'r'Description
TRUEnever evaluated
FALSEnever evaluated
0
5995 temp[0] = '\r';
never executed: temp[0] = '\r';
0
5996 else /* (c == '\\') */-
5997 temp[0] = c;
never executed: temp[0] = c;
0
5998 temp[1] = '\0';-
5999 goto add_string;
never executed: goto add_string;
0
6000-
6001 default:
never executed: default:
0
6002not_escape:-
6003 temp = (char *)xmalloc (3);-
6004 temp[0] = '\\';-
6005 temp[1] = c;-
6006 temp[2] = '\0';-
6007-
6008 add_string:
code before this statement never executed: add_string:
0
6009 if (c)
cDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
6010 string++;
executed 2 times by 1 test: string++;
Executed by:
  • Self test
2
6011 result =-
6012 sub_append_string (temp, result, &result_index, &result_size);-
6013 temp = (char *)NULL; /* Freed in sub_append_string (). */-
6014 result[result_index] = '\0';-
6015 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
6016 }-
6017 }-
6018 else-
6019 {-
6020 RESIZE_MALLOCED_BUFFER (result, result_index, 3, result_size, PROMPT_GROWTH);
never executed: result_size += (48);
never executed: end of block
(result_index)...>= result_sizeDescription
TRUEnever evaluated
FALSEevaluated 237 times by 1 test
Evaluated by:
  • Self test
(result_index)...>= result_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-237
6021 /* dequote_string should take care of removing this if we are not-
6022 performing the rest of the word expansions. */-
6023 if (c == CTLESC || c == CTLNUL)
c == '\001'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 236 times by 1 test
Evaluated by:
  • Self test
c == '\177'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 235 times by 1 test
Evaluated by:
  • Self test
1-236
6024 result[result_index++] = CTLESC;
executed 2 times by 1 test: result[result_index++] = '\001';
Executed by:
  • Self test
2
6025 result[result_index++] = c;-
6026 result[result_index] = '\0';-
6027 }
executed 237 times by 1 test: end of block
Executed by:
  • Self test
237
6028 }-
6029#else /* !PROMPT_STRING_DECODE */-
6030 result = savestring (string);-
6031#endif /* !PROMPT_STRING_DECODE */-
6032-
6033 /* Save the delimiter stack and point `dstack' to temp space so any-
6034 command substitutions in the prompt string won't result in screwing-
6035 up the parser's quoting state. */-
6036 save_dstack = dstack;-
6037 dstack = temp_dstack;-
6038 dstack.delimiter_depth = 0;-
6039-
6040 /* Perform variable and parameter expansion and command substitution on-
6041 the prompt string. */-
6042 if (promptvars || posixly_correct)
promptvarsDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0-61
6043 {-
6044 last_exit_value = last_command_exit_value;-
6045 last_comsub_pid = last_command_subst_pid;-
6046 list = expand_prompt_string (result, Q_DOUBLE_QUOTES, 0);-
6047 free (result);-
6048 result = string_list (list);-
6049 dispose_words (list);-
6050 last_command_exit_value = last_exit_value;-
6051 last_command_subst_pid = last_comsub_pid;-
6052 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
6053 else-
6054 {-
6055 t = dequote_string (result);-
6056 free (result);-
6057 result = t;-
6058 }
never executed: end of block
0
6059-
6060 dstack = save_dstack;-
6061-
6062 return (result);
executed 61 times by 1 test: return (result);
Executed by:
  • Self test
61
6063}-
6064-
6065/************************************************-
6066 * *-
6067 * ERROR HANDLING *-
6068 * *-
6069 ************************************************/-
6070-
6071/* Report a syntax error, and restart the parser. Call here for fatal-
6072 errors. */-
6073int-
6074yyerror (msg)-
6075 const char *msg;-
6076{-
6077 report_syntax_error ((char *)NULL);-
6078 reset_parser ();-
6079 return (0);
executed 44 times by 1 test: return (0);
Executed by:
  • Self test
44
6080}-
6081-
6082static char *-
6083error_token_from_token (tok)-
6084 int tok;-
6085{-
6086 char *t;-
6087-
6088 if (t = find_token_in_alist (tok, word_token_alist, 0))
t = find_token...oken_alist, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
4-33
6089 return t;
executed 4 times by 1 test: return t;
Executed by:
  • Self test
4
6090-
6091 if (t = find_token_in_alist (tok, other_token_alist, 0))
t = find_token...oken_alist, 0)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7-26
6092 return t;
executed 26 times by 1 test: return t;
Executed by:
  • Self test
26
6093-
6094 t = (char *)NULL;-
6095 /* This stuff is dicy and needs closer inspection */-
6096 switch (current_token)-
6097 {-
6098 case WORD:
executed 7 times by 1 test: case 281:
Executed by:
  • Self test
7
6099 case ASSIGNMENT_WORD:
never executed: case 282:
0
6100 if (yylval.word)
yylval.wordDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
6101 t = savestring (yylval.word->word);
executed 7 times by 1 test: t = (char *)strcpy (sh_xmalloc((1 + strlen (yylval.word->word)), "./parse.y", 6101), (yylval.word->word));
Executed by:
  • Self test
7
6102 break;
executed 7 times by 1 test: break;
Executed by:
  • Self test
7
6103 case NUMBER:
never executed: case 284:
0
6104 t = itos (yylval.number);-
6105 break;
never executed: break;
0
6106 case ARITH_CMD:
never executed: case 285:
0
6107 if (yylval.word_list)
yylval.word_listDescription
TRUEnever evaluated
FALSEnever evaluated
0
6108 t = string_list (yylval.word_list);
never executed: t = string_list (yylval.word_list);
0
6109 break;
never executed: break;
0
6110 case ARITH_FOR_EXPRS:
never executed: case 286:
0
6111 if (yylval.word_list)
yylval.word_listDescription
TRUEnever evaluated
FALSEnever evaluated
0
6112 t = string_list_internal (yylval.word_list, " ; ");
never executed: t = string_list_internal (yylval.word_list, " ; ");
0
6113 break;
never executed: break;
0
6114 case COND_CMD:
never executed: case 287:
0
6115 t = (char *)NULL; /* punt */-
6116 break;
never executed: break;
0
6117 }-
6118-
6119 return t;
executed 7 times by 1 test: return t;
Executed by:
  • Self test
7
6120}-
6121-
6122static char *-
6123error_token_from_text ()-
6124{-
6125 char *msg, *t;-
6126 int token_end, i;-
6127-
6128 t = shell_input_line;-
6129 i = shell_input_line_index;-
6130 token_end = 0;-
6131 msg = (char *)NULL;-
6132-
6133 if (i && t[i] == '\0')
iDescription
TRUEnever evaluated
FALSEnever evaluated
t[i] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
6134 i--;
never executed: i--;
0
6135-
6136 while (i && (whitespace (t[i]) || t[i] == '\n'))
iDescription
TRUEnever evaluated
FALSEnever evaluated
((t[i]) == ' ')Description
TRUEnever evaluated
FALSEnever evaluated
((t[i]) == '\t')Description
TRUEnever evaluated
FALSEnever evaluated
t[i] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
6137 i--;
never executed: i--;
0
6138-
6139 if (i)
iDescription
TRUEnever evaluated
FALSEnever evaluated
0
6140 token_end = i + 1;
never executed: token_end = i + 1;
0
6141-
6142 while (i && (member (t[i], " \n\t;|&") == 0))
(t[i])Description
TRUEnever evaluated
FALSEnever evaluated
iDescription
TRUEnever evaluated
FALSEnever evaluated
(((t[i]) ? ((c...) ) : 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
6143 i--;
never executed: i--;
0
6144-
6145 while (i != token_end && (whitespace (t[i]) || t[i] == '\n'))
i != token_endDescription
TRUEnever evaluated
FALSEnever evaluated
((t[i]) == ' ')Description
TRUEnever evaluated
FALSEnever evaluated
((t[i]) == '\t')Description
TRUEnever evaluated
FALSEnever evaluated
t[i] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
6146 i++;
never executed: i++;
0
6147-
6148 /* Return our idea of the offending token. */-
6149 if (token_end || (i == 0 && token_end == 0))
token_endDescription
TRUEnever evaluated
FALSEnever evaluated
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
token_end == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6150 {-
6151 if (token_end)
token_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
6152 msg = substring (t, i, token_end);
never executed: msg = substring (t, i, token_end);
0
6153 else /* one-character token */-
6154 {-
6155 msg = (char *)xmalloc (2);-
6156 msg[0] = t[i];-
6157 msg[1] = '\0';-
6158 }
never executed: end of block
0
6159 }-
6160-
6161 return (msg);
never executed: return (msg);
0
6162}-
6163-
6164static void-
6165print_offending_line ()-
6166{-
6167 char *msg;-
6168 int token_end;-
6169-
6170 msg = savestring (shell_input_line);-
6171 token_end = strlen (msg);-
6172 while (token_end && msg[token_end - 1] == '\n')
token_endDescription
TRUEevaluated 73 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
msg[token_end - 1] == '\n'Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
0-73
6173 msg[--token_end] = '\0';
executed 36 times by 1 test: msg[--token_end] = '\0';
Executed by:
  • Self test
36
6174-
6175 parser_error (line_number, "`%s'", msg);-
6176 free (msg);-
6177}
executed 37 times by 1 test: end of block
Executed by:
  • Self test
37
6178-
6179/* Report a syntax error with line numbers, etc.-
6180 Call here for recoverable errors. If you have a message to print,-
6181 then place it in MESSAGE, otherwise pass NULL and this will figure-
6182 out an appropriate message for you. */-
6183static void-
6184report_syntax_error (message)-
6185 char *message;-
6186{-
6187 char *msg, *p;-
6188-
6189 if (message)
messageDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
1-44
6190 {-
6191 parser_error (line_number, "%s", message);-
6192 if (interactive && EOF_Reached)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
EOF_ReachedDescription
TRUEnever evaluated
FALSEnever evaluated
0-1
6193 EOF_Reached = 0;
never executed: EOF_Reached = 0;
0
6194 last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE;
parse_and_execute_levelDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
6195 return;
executed 1 time by 1 test: return;
Executed by:
  • Self test
1
6196 }-
6197-
6198 /* If the line of input we're reading is not null, try to find the-
6199 objectionable token. First, try to figure out what token the-
6200 parser's complaining about by looking at current_token. */-
6201 if (current_token != 0 && EOF_Reached == 0 && (msg = error_token_from_token (current_token)))
current_token != 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
EOF_Reached == 0Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(msg = error_t...urrent_token))Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-44
6202 {-
6203 if (ansic_shouldquote (msg))
ansic_shouldquote (msg)Description
TRUEnever evaluated
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
0-37
6204 {-
6205 p = ansic_quote (msg, 0, NULL);-
6206 free (msg);-
6207 msg = p;-
6208 }
never executed: end of block
0
6209 parser_error (line_number, _("syntax error near unexpected token `%s'"), msg);-
6210 free (msg);-
6211-
6212 if (interactive == 0)
interactive == 0Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-37
6213 print_offending_line ();
executed 37 times by 1 test: print_offending_line ();
Executed by:
  • Self test
37
6214-
6215 last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE;
parse_and_execute_levelDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
11-26
6216 return;
executed 37 times by 1 test: return;
Executed by:
  • Self test
37
6217 }-
6218-
6219 /* If looking at the current token doesn't prove fruitful, try to find the-
6220 offending token by analyzing the text of the input line near the current-
6221 input line index and report what we find. */-
6222 if (shell_input_line && *shell_input_line)
shell_input_lineDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*shell_input_lineDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-7
6223 {-
6224 msg = error_token_from_text ();-
6225 if (msg)
msgDescription
TRUEnever evaluated
FALSEnever evaluated
0
6226 {-
6227 parser_error (line_number, _("syntax error near `%s'"), msg);-
6228 free (msg);-
6229 }
never executed: end of block
0
6230-
6231 /* If not interactive, print the line containing the error. */-
6232 if (interactive == 0)
interactive == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6233 print_offending_line ();
never executed: print_offending_line ();
0
6234 }
never executed: end of block
0
6235 else-
6236 {-
6237 msg = EOF_Reached ? _("syntax error: unexpected end of file") : _("syntax error");
EOF_ReachedDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
6238 parser_error (line_number, "%s", msg);-
6239 /* When the shell is interactive, this file uses EOF_Reached-
6240 only for error reporting. Other mechanisms are used to-
6241 decide whether or not to exit. */-
6242 if (interactive && EOF_Reached)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
EOF_ReachedDescription
TRUEnever evaluated
FALSEnever evaluated
0-7
6243 EOF_Reached = 0;
never executed: EOF_Reached = 0;
0
6244 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
6245-
6246 last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE;
parse_and_execute_levelDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
3-4
6247}
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
6248-
6249/* ??? Needed function. ??? We have to be able to discard the constructs-
6250 created during parsing. In the case of error, we want to return-
6251 allocated objects to the memory pool. In the case of no error, we want-
6252 to throw away the information about where the allocated objects live.-
6253 (dispose_command () will actually free the command.) */-
6254static void-
6255discard_parser_constructs (error_p)-
6256 int error_p;-
6257{-
6258}-
6259-
6260/************************************************-
6261 * *-
6262 * EOF HANDLING *-
6263 * *-
6264 ************************************************/-
6265-
6266/* Do that silly `type "bye" to exit' stuff. You know, "ignoreeof". */-
6267-
6268/* A flag denoting whether or not ignoreeof is set. */-
6269int ignoreeof = 0;-
6270-
6271/* The number of times that we have encountered an EOF character without-
6272 another character intervening. When this gets above the limit, the-
6273 shell terminates. */-
6274int eof_encountered = 0;-
6275-
6276/* The limit for eof_encountered. */-
6277int eof_encountered_limit = 10;-
6278-
6279/* If we have EOF as the only input unit, this user wants to leave-
6280 the shell. If the shell is not interactive, then just leave.-
6281 Otherwise, if ignoreeof is set, and we haven't done this the-
6282 required number of times in a row, print a message. */-
6283static void-
6284handle_eof_input_unit ()-
6285{-
6286 if (interactive)
interactiveDescription
TRUEnever evaluated
FALSEevaluated 1292 times by 1 test
Evaluated by:
  • Self test
0-1292
6287 {-
6288 /* shell.c may use this to decide whether or not to write out the-
6289 history, among other things. We use it only for error reporting-
6290 in this file. */-
6291 if (EOF_Reached)
EOF_ReachedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6292 EOF_Reached = 0;
never executed: EOF_Reached = 0;
0
6293-
6294 /* If the user wants to "ignore" eof, then let her do so, kind of. */-
6295 if (ignoreeof)
ignoreeofDescription
TRUEnever evaluated
FALSEnever evaluated
0
6296 {-
6297 if (eof_encountered < eof_encountered_limit)
eof_encountere...ountered_limitDescription
TRUEnever evaluated
FALSEnever evaluated
0
6298 {-
6299 fprintf (stderr, _("Use \"%s\" to leave the shell.\n"),-
6300 login_shell ? "logout" : "exit");-
6301 eof_encountered++;-
6302 /* Reset the parsing state. */-
6303 last_read_token = current_token = '\n';-
6304 /* Reset the prompt string to be $PS1. */-
6305 prompt_string_pointer = (char **)NULL;-
6306 prompt_again ();-
6307 return;
never executed: return;
0
6308 }-
6309 }
never executed: end of block
0
6310-
6311 /* In this case EOF should exit the shell. Do it now. */-
6312 reset_parser ();-
6313 exit_builtin ((WORD_LIST *)NULL);-
6314 }
never executed: end of block
0
6315 else-
6316 {-
6317 /* We don't write history files, etc., for non-interactive shells. */-
6318 EOF_Reached = 1;-
6319 }
executed 1292 times by 1 test: end of block
Executed by:
  • Self test
1292
6320}-
6321-
6322/************************************************-
6323 * *-
6324 * STRING PARSING FUNCTIONS *-
6325 * *-
6326 ************************************************/-
6327-
6328/* It's very important that these two functions treat the characters-
6329 between ( and ) identically. */-
6330-
6331static WORD_LIST parse_string_error;-
6332-
6333/* Take a string and run it through the shell parser, returning the-
6334 resultant word list. Used by compound array assignment. */-
6335WORD_LIST *-
6336parse_string_to_word_list (s, flags, whom)-
6337 char *s;-
6338 int flags;-
6339 const char *whom;-
6340{-
6341 WORD_LIST *wl;-
6342 int tok, orig_current_token, orig_line_number, orig_input_terminator;-
6343 int orig_line_count;-
6344 int old_echo_input, old_expand_aliases;-
6345#if defined (HISTORY)-
6346 int old_remember_on_history, old_history_expansion_inhibited;-
6347#endif-
6348-
6349#if defined (HISTORY)-
6350 old_remember_on_history = remember_on_history;-
6351# if defined (BANG_HISTORY)-
6352 old_history_expansion_inhibited = history_expansion_inhibited;-
6353# endif-
6354 bash_history_disable ();-
6355#endif-
6356-
6357 orig_line_number = line_number;-
6358 orig_line_count = current_command_line_count;-
6359 orig_input_terminator = shell_input_line_terminator;-
6360 old_echo_input = echo_input_at_read;-
6361 old_expand_aliases = expand_aliases;-
6362-
6363 push_stream (1);-
6364 last_read_token = WORD; /* WORD to allow reserved words here */-
6365 current_command_line_count = 0;-
6366 echo_input_at_read = expand_aliases = 0;-
6367-
6368 with_input_from_string (s, whom);-
6369 wl = (WORD_LIST *)NULL;-
6370-
6371 if (flags & 1)
flags & 1Description
TRUEevaluated 515 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-515
6372 parser_state |= PST_COMPASSIGN|PST_REPARSE;
executed 515 times by 1 test: parser_state |= 0x002000|0x040000;
Executed by:
  • Self test
515
6373-
6374 while ((tok = read_token (READ)) != yacc_EOF)
(tok = read_token (0)) != 304Description
TRUEevaluated 3477 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
28-3477
6375 {-
6376 if (tok == '\n' && *bash_input.location.string == '\0')
tok == '\n'Description
TRUEevaluated 487 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2990 times by 1 test
Evaluated by:
  • Self test
*bash_input.lo...string == '\0'Description
TRUEevaluated 487 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2990
6377 break;
executed 487 times by 1 test: break;
Executed by:
  • Self test
487
6378 if (tok == '\n') /* Allow newlines in compound assignments */
tok == '\n'Description
TRUEnever evaluated
FALSEevaluated 2990 times by 1 test
Evaluated by:
  • Self test
0-2990
6379 continue;
never executed: continue;
0
6380 if (tok != WORD && tok != ASSIGNMENT_WORD)
tok != 281Description
TRUEevaluated 2112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 878 times by 1 test
Evaluated by:
  • Self test
tok != 282Description
TRUEnever evaluated
FALSEevaluated 2112 times by 1 test
Evaluated by:
  • Self test
0-2112
6381 {-
6382 line_number = orig_line_number + line_number - 1;-
6383 orig_current_token = current_token;-
6384 current_token = tok;-
6385 yyerror (NULL); /* does the right thing */-
6386 current_token = orig_current_token;-
6387 if (wl)
wlDescription
TRUEnever evaluated
FALSEnever evaluated
0
6388 dispose_words (wl);
never executed: dispose_words (wl);
0
6389 wl = &parse_string_error;-
6390 break;
never executed: break;
0
6391 }-
6392 wl = make_word_list (yylval.word, wl);-
6393 }
executed 2990 times by 1 test: end of block
Executed by:
  • Self test
2990
6394 -
6395 last_read_token = '\n';-
6396 pop_stream ();-
6397-
6398#if defined (HISTORY)-
6399 remember_on_history = old_remember_on_history;-
6400# if defined (BANG_HISTORY)-
6401 history_expansion_inhibited = old_history_expansion_inhibited;-
6402# endif /* BANG_HISTORY */-
6403#endif /* HISTORY */-
6404-
6405 echo_input_at_read = old_echo_input;-
6406 expand_aliases = old_expand_aliases;-
6407-
6408 current_command_line_count = orig_line_count;-
6409 shell_input_line_terminator = orig_input_terminator;-
6410-
6411 if (flags & 1)
flags & 1Description
TRUEevaluated 515 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-515
6412 parser_state &= ~(PST_COMPASSIGN|PST_REPARSE);
executed 515 times by 1 test: parser_state &= ~(0x002000|0x040000);
Executed by:
  • Self test
515
6413-
6414 if (wl == &parse_string_error)
wl == &parse_string_errorDescription
TRUEnever evaluated
FALSEevaluated 515 times by 1 test
Evaluated by:
  • Self test
0-515
6415 {-
6416 last_command_exit_value = EXECUTION_FAILURE;-
6417 if (interactive_shell == 0 && posixly_correct)
interactive_shell == 0Description
TRUEnever evaluated
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0
6418 jump_to_top_level (FORCE_EOF);
never executed: jump_to_top_level (1);
0
6419 else-
6420 jump_to_top_level (DISCARD);
never executed: jump_to_top_level (2);
0
6421 }-
6422-
6423 return (REVERSE_LIST (wl, WORD_LIST *));
executed 515 times by 1 test: return (((wl && wl->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)wl) : (WORD_LIST *)(wl)));
Executed by:
  • Self test
515
6424}-
6425-
6426static char *-
6427parse_compound_assignment (retlenp)-
6428 int *retlenp;-
6429{-
6430 WORD_LIST *wl, *rl;-
6431 int tok, orig_line_number, orig_token_size, orig_last_token, assignok;-
6432 char *saved_token, *ret;-
6433-
6434 saved_token = token;-
6435 orig_token_size = token_buffer_size;-
6436 orig_line_number = line_number;-
6437 orig_last_token = last_read_token;-
6438-
6439 last_read_token = WORD; /* WORD to allow reserved words here */-
6440-
6441 token = (char *)NULL;-
6442 token_buffer_size = 0;-
6443-
6444 assignok = parser_state&PST_ASSIGNOK; /* XXX */-
6445-
6446 wl = (WORD_LIST *)NULL; /* ( */-
6447 parser_state |= PST_COMPASSIGN;-
6448-
6449 while ((tok = read_token (READ)) != ')')
(tok = read_token (0)) != ')'Description
TRUEevaluated 3673 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 708 times by 1 test
Evaluated by:
  • Self test
708-3673
6450 {-
6451 if (tok == '\n') /* Allow newlines in compound assignments */
tok == '\n'Description
TRUEevaluated 526 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3147 times by 1 test
Evaluated by:
  • Self test
526-3147
6452 {-
6453 if (SHOULD_PROMPT ())
interactiveDescription
TRUEnever evaluated
FALSEevaluated 526 times by 1 test
Evaluated by:
  • Self test
bash_input.type == st_stdinDescription
TRUEnever evaluated
FALSEnever evaluated
bash_input.type == st_streamDescription
TRUEnever evaluated
FALSEnever evaluated
0-526
6454 prompt_again ();
never executed: prompt_again ();
0
6455 continue;
executed 526 times by 1 test: continue;
Executed by:
  • Self test
526
6456 }-
6457 if (tok != WORD && tok != ASSIGNMENT_WORD)
tok != 281Description
TRUEevaluated 2076 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1071 times by 1 test
Evaluated by:
  • Self test
tok != 282Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2059 times by 1 test
Evaluated by:
  • Self test
17-2076
6458 {-
6459 current_token = tok; /* for error reporting */-
6460 if (tok == yacc_EOF) /* ( */
tok == 304Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-17
6461 parser_error (orig_line_number, _("unexpected EOF while looking for matching `)'"));
never executed: parser_error (orig_line_number, dcgettext (((void *)0), "unexpected EOF while looking for matching `)'" , 5) );
0
6462 else-
6463 yyerror(NULL); /* does the right thing */
executed 17 times by 1 test: yyerror( ((void *)0) );
Executed by:
  • Self test
17
6464 if (wl)
wlDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-16
6465 dispose_words (wl);
executed 16 times by 1 test: dispose_words (wl);
Executed by:
  • Self test
16
6466 wl = &parse_string_error;-
6467 break;
executed 17 times by 1 test: break;
Executed by:
  • Self test
17
6468 }-
6469 wl = make_word_list (yylval.word, wl);-
6470 }
executed 3130 times by 1 test: end of block
Executed by:
  • Self test
3130
6471-
6472 FREE (token);
executed 660 times by 1 test: sh_xfree((token), "./parse.y", 6472);
Executed by:
  • Self test
tokenDescription
TRUEevaluated 660 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
65-660
6473 token = saved_token;-
6474 token_buffer_size = orig_token_size;-
6475-
6476 parser_state &= ~PST_COMPASSIGN;-
6477-
6478 if (wl == &parse_string_error)
wl == &parse_string_errorDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 708 times by 1 test
Evaluated by:
  • Self test
17-708
6479 {-
6480 last_command_exit_value = EXECUTION_FAILURE;-
6481 last_read_token = '\n'; /* XXX */-
6482 if (interactive_shell == 0 && posixly_correct)
interactive_shell == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-17
6483 jump_to_top_level (FORCE_EOF);
never executed: jump_to_top_level (1);
0
6484 else-
6485 jump_to_top_level (DISCARD);
executed 17 times by 1 test: jump_to_top_level (2);
Executed by:
  • Self test
17
6486 }-
6487-
6488 last_read_token = orig_last_token; /* XXX - was WORD? */-
6489-
6490 if (wl)
wlDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
64-644
6491 {-
6492 rl = REVERSE_LIST (wl, WORD_LIST *);
wlDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
wl->nextDescription
TRUEevaluated 279 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 365 times by 1 test
Evaluated by:
  • Self test
0-644
6493 ret = string_list (rl);-
6494 dispose_words (rl);-
6495 }
executed 644 times by 1 test: end of block
Executed by:
  • Self test
644
6496 else-
6497 ret = (char *)NULL;
executed 64 times by 1 test: ret = (char *) ((void *)0) ;
Executed by:
  • Self test
64
6498-
6499 if (retlenp)
retlenpDescription
TRUEevaluated 708 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-708
6500 *retlenp = (ret && *ret) ? strlen (ret) : 0;
executed 708 times by 1 test: *retlenp = (ret && *ret) ? strlen (ret) : 0;
Executed by:
  • Self test
retDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
*retDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-708
6501-
6502 if (assignok)
assignokDescription
TRUEevaluated 122 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 586 times by 1 test
Evaluated by:
  • Self test
122-586
6503 parser_state |= PST_ASSIGNOK;
executed 122 times by 1 test: parser_state |= 0x004000;
Executed by:
  • Self test
122
6504-
6505 return ret;
executed 708 times by 1 test: return ret;
Executed by:
  • Self test
708
6506}-
6507-
6508/************************************************-
6509 * *-
6510 * SAVING AND RESTORING PARTIAL PARSE STATE *-
6511 * *-
6512 ************************************************/-
6513-
6514sh_parser_state_t *-
6515save_parser_state (ps)-
6516 sh_parser_state_t *ps;-
6517{-
6518 if (ps == 0)
ps == 0Description
TRUEnever evaluated
FALSEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
0-707380
6519 ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t));
never executed: ps = (sh_parser_state_t *)sh_xmalloc((sizeof (sh_parser_state_t)), "./parse.y", 6519);
0
6520 if (ps == 0)
ps == 0Description
TRUEnever evaluated
FALSEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
0-707380
6521 return ((sh_parser_state_t *)NULL);
never executed: return ((sh_parser_state_t *) ((void *)0) );
0
6522-
6523 ps->parser_state = parser_state;-
6524 ps->token_state = save_token_state ();-
6525-
6526 ps->input_line_terminator = shell_input_line_terminator;-
6527 ps->eof_encountered = eof_encountered;-
6528-
6529 ps->prompt_string_pointer = prompt_string_pointer;-
6530-
6531 ps->current_command_line_count = current_command_line_count;-
6532-
6533#if defined (HISTORY)-
6534 ps->remember_on_history = remember_on_history;-
6535# if defined (BANG_HISTORY)-
6536 ps->history_expansion_inhibited = history_expansion_inhibited;-
6537# endif-
6538#endif-
6539-
6540 ps->last_command_exit_value = last_command_exit_value;-
6541#if defined (ARRAY_VARS)-
6542 ps->pipestatus = save_pipestatus_array ();-
6543#endif-
6544 -
6545 ps->last_shell_builtin = last_shell_builtin;-
6546 ps->this_shell_builtin = this_shell_builtin;-
6547-
6548 ps->expand_aliases = expand_aliases;-
6549 ps->echo_input_at_read = echo_input_at_read;-
6550 ps->need_here_doc = need_here_doc;-
6551 ps->here_doc_first_line = here_doc_first_line;-
6552-
6553 if (need_here_doc == 0)
need_here_doc == 0Description
TRUEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-707380
6554 ps->redir_stack[0] = 0;
executed 707380 times by 1 test: ps->redir_stack[0] = 0;
Executed by:
  • Self test
707380
6555 else-
6556 memcpy (ps->redir_stack, redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX);
never executed: memcpy (ps->redir_stack, redir_stack, sizeof (redir_stack[0]) * 16);
0
6557-
6558 ps->token = token;-
6559 ps->token_buffer_size = token_buffer_size;-
6560 /* Force reallocation on next call to read_token_word */-
6561 token = 0;-
6562 token_buffer_size = 0;-
6563-
6564 return (ps);
executed 707380 times by 1 test: return (ps);
Executed by:
  • Self test
707380
6565}-
6566-
6567void-
6568restore_parser_state (ps)-
6569 sh_parser_state_t *ps;-
6570{-
6571 int i;-
6572-
6573 if (ps == 0)
ps == 0Description
TRUEnever evaluated
FALSEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
0-707380
6574 return;
never executed: return;
0
6575-
6576 parser_state = ps->parser_state;-
6577 if (ps->token_state)
ps->token_stateDescription
TRUEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-707380
6578 {-
6579 restore_token_state (ps->token_state);-
6580 free (ps->token_state);-
6581 }
executed 707380 times by 1 test: end of block
Executed by:
  • Self test
707380
6582-
6583 shell_input_line_terminator = ps->input_line_terminator;-
6584 eof_encountered = ps->eof_encountered;-
6585-
6586 prompt_string_pointer = ps->prompt_string_pointer;-
6587-
6588 current_command_line_count = ps->current_command_line_count;-
6589-
6590#if defined (HISTORY)-
6591 remember_on_history = ps->remember_on_history;-
6592# if defined (BANG_HISTORY)-
6593 history_expansion_inhibited = ps->history_expansion_inhibited;-
6594# endif-
6595#endif-
6596-
6597 last_command_exit_value = ps->last_command_exit_value;-
6598#if defined (ARRAY_VARS)-
6599 restore_pipestatus_array (ps->pipestatus);-
6600#endif-
6601-
6602 last_shell_builtin = ps->last_shell_builtin;-
6603 this_shell_builtin = ps->this_shell_builtin;-
6604-
6605 expand_aliases = ps->expand_aliases;-
6606 echo_input_at_read = ps->echo_input_at_read;-
6607 need_here_doc = ps->need_here_doc;-
6608 here_doc_first_line = ps->here_doc_first_line;-
6609-
6610#if 0-
6611 for (i = 0; i < HEREDOC_MAX; i++)-
6612 redir_stack[i] = ps->redir_stack[i];-
6613#else-
6614 if (need_here_doc == 0)
need_here_doc == 0Description
TRUEevaluated 707380 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-707380
6615 redir_stack[0] = 0;
executed 707380 times by 1 test: redir_stack[0] = 0;
Executed by:
  • Self test
707380
6616 else-
6617 memcpy (redir_stack, ps->redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX);
never executed: memcpy (redir_stack, ps->redir_stack, sizeof (redir_stack[0]) * 16);
0
6618#endif-
6619-
6620 FREE (token);
executed 707228 times by 1 test: sh_xfree((token), "./parse.y", 6620);
Executed by:
  • Self test
tokenDescription
TRUEevaluated 707228 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 152 times by 1 test
Evaluated by:
  • Self test
152-707228
6621 token = ps->token;-
6622 token_buffer_size = ps->token_buffer_size;-
6623}
executed 707380 times by 1 test: end of block
Executed by:
  • Self test
707380
6624-
6625sh_input_line_state_t *-
6626save_input_line_state (ls)-
6627 sh_input_line_state_t *ls;-
6628{-
6629 if (ls == 0)
ls == 0Description
TRUEnever evaluated
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-705307
6630 ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
never executed: ls = (sh_input_line_state_t *)sh_xmalloc((sizeof (sh_input_line_state_t)), "./parse.y", 6630);
0
6631 if (ls == 0)
ls == 0Description
TRUEnever evaluated
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-705307
6632 return ((sh_input_line_state_t *)NULL);
never executed: return ((sh_input_line_state_t *) ((void *)0) );
0
6633-
6634 ls->input_line = shell_input_line;-
6635 ls->input_line_size = shell_input_line_size;-
6636 ls->input_line_len = shell_input_line_len;-
6637 ls->input_line_index = shell_input_line_index;-
6638-
6639 /* force reallocation */-
6640 shell_input_line = 0;-
6641 shell_input_line_size = shell_input_line_len = shell_input_line_index = 0;-
6642-
6643 return ls;
executed 705307 times by 1 test: return ls;
Executed by:
  • Self test
705307
6644}-
6645-
6646void-
6647restore_input_line_state (ls)-
6648 sh_input_line_state_t *ls;-
6649{-
6650 FREE (shell_input_line);
never executed: sh_xfree((shell_input_line), "./parse.y", 6650);
shell_input_lineDescription
TRUEnever evaluated
FALSEevaluated 705307 times by 1 test
Evaluated by:
  • Self test
0-705307
6651 shell_input_line = ls->input_line;-
6652 shell_input_line_size = ls->input_line_size;-
6653 shell_input_line_len = ls->input_line_len;-
6654 shell_input_line_index = ls->input_line_index;-
6655-
6656 set_line_mbstate ();-
6657}
executed 705307 times by 1 test: end of block
Executed by:
  • Self test
705307
6658-
6659/************************************************-
6660 * *-
6661 * MULTIBYTE CHARACTER HANDLING *-
6662 * *-
6663 ************************************************/-
6664-
6665#if defined (HANDLE_MULTIBYTE)-
6666-
6667/* We don't let the property buffer get larger than this unless the line is */-
6668#define MAX_PROPSIZE 32768-
6669-
6670static void-
6671set_line_mbstate ()-
6672{-
6673 int c;-
6674 size_t i, previ, len;-
6675 mbstate_t mbs, prevs;-
6676 size_t mbclen;-
6677-
6678 if (shell_input_line == NULL)
shell_input_li...== ((void *)0)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3635148 times by 1 test
Evaluated by:
  • Self test
22-3635148
6679 return;
executed 22 times by 1 test: return;
Executed by:
  • Self test
22
6680 len = strlen (shell_input_line); /* XXX - shell_input_line_len ? */-
6681 if (len == 0)
len == 0Description
TRUEevaluated 63687 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3571461 times by 1 test
Evaluated by:
  • Self test
63687-3571461
6682 return;
executed 63687 times by 1 test: return;
Executed by:
  • Self test
63687
6683 if (shell_input_line_propsize >= MAX_PROPSIZE && len < MAX_PROPSIZE>>1)
shell_input_li...psize >= 32768Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3571459 times by 1 test
Evaluated by:
  • Self test
len < 32768>>1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-3571459
6684 {-
6685 free (shell_input_line_property);-
6686 shell_input_line_property = 0;-
6687 shell_input_line_propsize = 0;-
6688 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
6689 if (len+1 > shell_input_line_propsize)
len+1 > shell_..._line_propsizeDescription
TRUEevaluated 58269 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3513192 times by 1 test
Evaluated by:
  • Self test
58269-3513192
6690 {-
6691 shell_input_line_propsize = len + 1;-
6692 shell_input_line_property = (char *)xrealloc (shell_input_line_property, shell_input_line_propsize);-
6693 }
executed 58269 times by 1 test: end of block
Executed by:
  • Self test
58269
6694-
6695 /* XXX - use whether or not we are in a UTF-8 locale to avoid calls to-
6696 mbrlen */-
6697 memset (&prevs, '\0', sizeof (mbstate_t));-
6698 for (i = previ = 0; i < len; i++)
i < lenDescription
TRUEevaluated 43543997 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3571461 times by 1 test
Evaluated by:
  • Self test
3571461-43543997
6699 {-
6700 mbs = prevs;-
6701-
6702 c = shell_input_line[i];-
6703 if (c == EOF)
c == (-1)Description
TRUEnever evaluated
FALSEevaluated 43543997 times by 1 test
Evaluated by:
  • Self test
0-43543997
6704 {-
6705 size_t j;-
6706 for (j = i; j < len; j++)
j < lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
6707 shell_input_line_property[j] = 1;
never executed: shell_input_line_property[j] = 1;
0
6708 break;
never executed: break;
0
6709 }-
6710-
6711 /* I'd love to take more advantage of UTF-8's properties in a UTF-8-
6712 locale, but mbrlen changes the mbstate_t on every call even when-
6713 presented with single-byte characters. */-
6714 mbclen = mbrlen (shell_input_line + previ, i - previ + 1, &mbs);-
6715 if (mbclen == 1 || mbclen == (size_t)-1)
mbclen == 1Description
TRUEevaluated 43536721 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7276 times by 1 test
Evaluated by:
  • Self test
mbclen == (size_t)-1Description
TRUEevaluated 426 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6850 times by 1 test
Evaluated by:
  • Self test
426-43536721
6716 {-
6717 mbclen = 1;-
6718 previ = i + 1;-
6719 }
executed 43537147 times by 1 test: end of block
Executed by:
  • Self test
43537147
6720 else if (mbclen == (size_t)-2)
mbclen == (size_t)-2Description
TRUEevaluated 4352 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2498 times by 1 test
Evaluated by:
  • Self test
2498-4352
6721 mbclen = 0;
executed 4352 times by 1 test: mbclen = 0;
Executed by:
  • Self test
4352
6722 else if (mbclen > 1)
mbclen > 1Description
TRUEevaluated 2498 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2498
6723 {-
6724 mbclen = 0;-
6725 previ = i + 1;-
6726 prevs = mbs;-
6727 }
executed 2498 times by 1 test: end of block
Executed by:
  • Self test
2498
6728 else-
6729 {-
6730 /* XXX - what to do if mbrlen returns 0? (null wide character) */-
6731 size_t j;-
6732 for (j = i; j < len; j++)
j < lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
6733 shell_input_line_property[j] = 1;
never executed: shell_input_line_property[j] = 1;
0
6734 break;
never executed: break;
0
6735 }-
6736-
6737 shell_input_line_property[i] = mbclen;-
6738 }
executed 43543997 times by 1 test: end of block
Executed by:
  • Self test
43543997
6739}
executed 3571461 times by 1 test: end of block
Executed by:
  • Self test
3571461
6740#endif /* HANDLE_MULTIBYTE */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2