summaryrefslogtreecommitdiffstats
path: root/src/ft_echo.c
blob: 66d803fa0385f8c1c8ae2bb26f6b898f797c65ca (plain)
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
#include <libft.h>
#include <minishell.h>
#include <inttypes.h>

int
ft_echo(char **com, uint8_t n)
{
	uint8_t i;
	int fd;

	i = 1;
	fd = 1;
	if (!com[1])
		ft_putendl_fd("", fd);
	else if (ft_strncmp(com[1], "-n", ft_strlen(com[1])))
	{
		while (i < n)
		{
			ft_putendl_fd(com[i], fd);
			i++;
		}
	}
	else
	{
		while (i < n)
		{
			ft_putstr_fd(com[i], fd);
			i++;
		}
	}
	return (0);
}