-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo.c
40 lines (37 loc) · 1.28 KB
/
echo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* echo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: almelo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/07 17:45:47 by almelo #+# #+# */
/* Updated: 2023/03/20 22:07:01 by dioda-si ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void echo(int argc, char **argv)
{
size_t i;
enum e_bool end_nl;
end_nl = TRUE;
if (argc > 1)
{
i = 1;
if (ft_strcmp(argv[i], "-n") == 0)
{
end_nl = FALSE;
i++;
}
while (argv[i])
{
ft_putstr_fd(argv[i], STDOUT_FILENO);
if (argv[i + 1])
ft_putchar_fd(' ', STDOUT_FILENO);
i++;
}
}
if (end_nl == TRUE)
ft_putchar_fd('\n', STDOUT_FILENO);
exit(0);
}