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</