GCC Code Coverage Report


Directory: ./
File: src/builtins/repeat.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 1 1 100.0%
Branches: 7 8 87.5%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The file containing the repeat builtins
6 */
7 /**
8 * @file repeat.c
9 * @brief The file containing the repeat builtins
10 */
11
12 #include "../../include/myshell.h"
13
14 /**
15 * @brief The repeat builtin
16 * @param mysh The shell structure
17 * @return <b>int</b> <u>0</u> if the command succeed, <u>1</u> otherwise
18 */
19 12 int exec_repeat(mysh_t *mysh)
20 {
21 12 int count = 0;
22 12 pid_t child_pid = 0;
23 12 input_command_t *input_command = NULL;
24
25
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
12 if (mysh->args[1] == NULL || mysh->args[2] == NULL) {
26 7 my_putstr_error("repeat: Too few arguments.\n");
27 7 return 1;
28 }
29 5 count = my_super_number(mysh->args[1], (NB){0, 0, 0, 1});
30
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (my_errno == 1) {
31 3 my_putstr_error("repeat: Badly formed number.\n");
32 3 return 1;
33 }
34 2 input_command = malloc(sizeof(input_command_t));
35 2 input_command->args = &mysh->args[2];
36
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for (int index = 0; index < count; index++)
37 4 command(mysh, input_command);
38 2 return mysh->exit_status;
39 }
40