-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_error2.c
53 lines (49 loc) · 1.47 KB
/
check_error2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_error2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wlalaoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 10:45:25 by wlalaoui #+# #+# */
/* Updated: 2024/01/18 11:50:42 by wlalaoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
bool check_letter_before(const char *command_line, ssize_t i, bool is_pipe)
{
i -= 1;
if (i == 0)
{
if (is_metacharacter(command_line[i]))
return (1);
return (0);
}
while (i > 0)
{
while (is_blank(command_line[i]))
i--;
if (is_pipe)
{
if (command_line[i] == '|')
return (1);
}
else if (!is_pipe)
{
if (is_metacharacter(command_line[i]))
return (1);
}
return (0);
}
return (1);
}
bool check_only_blanks(const char *command_line)
{
int i;
i = 0;
while (is_blank(command_line[i]))
i++;
if (!command_line[i])
return (1);
return (0);
}