-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo.c
38 lines (35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* echo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malatini <malatini@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/30 15:39:47 by labintei #+# #+# */
/* Updated: 2021/09/22 18:14:26 by labintei ### ########.fr */
/* */
/* ************************************************************************** */
#include "../minishell.h"
int echo_build(t_list *cmds)
{
int i;
int g;
i = 1;
g = 0;
if (cmds->cmds && cmds->cmds[0] && cmds->cmds[1] && \
ft_strcmp(cmds->cmds[i], "-n"))
{
g = 1;
i++;
}
while (cmds->cmds && cmds->cmds[0] && cmds->cmds[i])
{
write(1, cmds->cmds[i], ft_strlen(cmds->cmds[i]));
if (cmds->cmds[i + 1])
write(1, " ", 1);
i++;
}
if (g != 1)
write(1, "\n", 1);
return (0);
}