Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2024 | ||
3 | ** 42sh | ||
4 | ** File description: | ||
5 | ** The file containing the echo builtin | ||
6 | */ | ||
7 | /** | ||
8 | * @file echo.c | ||
9 | * @brief The file containing the echo builtin | ||
10 | */ | ||
11 | |||
12 | #include "../../include/myshell.h" | ||
13 | |||
14 | /** | ||
15 | * @brief The echo builtin | ||
16 | * @param mysh The shell structure | ||
17 | * @return <b>int</b> The exit status of the echo command | ||
18 | */ | ||
19 | 28 | int exec_echo(mysh_t *mysh) | |
20 | { | ||
21 | 28 | char **tmp = globbing(mysh->args); | |
22 | 28 | int index = 1; | |
23 | |||
24 |
2/4✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
|
28 | if (tmp == NULL || tmp[0] == NULL) |
25 | ✗ | return 1; | |
26 | 28 | mysh->args = my_malloc_strdup_word_array(tmp); | |
27 | 28 | FREE(tmp); | |
28 |
3/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
28 | if (mysh->args[1] != NULL && my_strcmp(mysh->args[1], "-n") == 0) |
29 | ✗ | index = 2; | |
30 |
2/2✓ Branch 0 taken 1060 times.
✓ Branch 1 taken 28 times.
|
1088 | for (; mysh->args[index] != NULL; index++) { |
31 | 1060 | my_putstr(mysh->args[index]); | |
32 |
2/2✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 25 times.
|
1060 | if (mysh->args[index + 1] != NULL) |
33 | 1035 | my_putchar(' '); | |
34 | } | ||
35 |
3/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
28 | if (mysh->args[1] == NULL || my_strcmp(mysh->args[1], "-n") != 0) |
36 | 28 | my_putchar('\n'); | |
37 | 28 | return 0; | |
38 | } | ||
39 |