-
Notifications
You must be signed in to change notification settings - Fork 0
/
min_echo.c
executable file
·63 lines (58 loc) · 1.44 KB
/
min_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* min_echo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pmoreno- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/30 11:13:18 by potero-d #+# #+# */
/* Updated: 2022/08/02 18:50:09 by pmoreno- ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int check_flags(char *flag)
{
int i;
int len;
i = 0;
if (flag[i] == '-')
{
i++;
len = ft_strlen(flag);
while (i < len)
{
if (flag[i] != 'n')
return (1);
i++;
}
}
else
return (1);
return (0);
}
void min_echo(t_argv **argv)
{
t_argv *aux;
int i;
int n;
n = 0;
aux = *argv;
i = 1;
if (aux->split[i])
{
while (check_flags(aux->split[i]) == 0)
{
n = 1;
i++;
}
while (aux->split[i])
{
printf("%s", aux->split[i]);
i++;
if (aux->split[i] != 0)
printf(" ");
}
}
if (n == 0)
printf("\n");
}