forked from ayzezzz/42cursus-minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror2.c
55 lines (50 loc) · 1.87 KB
/
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
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: itulgar < itulgar@student.42istanbul.co +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/06 21:21:02 by zayaz #+# #+# */
/* Updated: 2024/11/08 17:10:44 by itulgar ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void exit_error(char *cmd, char *s, char *message)
{
write(2, "minishell: ", ft_strlen("minishell: "));
write(2, cmd, ft_strlen(cmd));
write(2, ":", 1);
write(2, " ", 1);
if (s[0] != '\0')
write(2, s, ft_strlen(s));
write(2, message, ft_strlen(message));
write(2, "\n", 1);
}
void build_error(t_program *program, char *cmd, char *message)
{
program->status = 1;
write(2, "minishell: ", ft_strlen("minishell: "));
write(2, cmd, ft_strlen(cmd));
write(2, ":", 1);
write(2, message, ft_strlen(message));
write(2, "\n", 1);
}
void identifier_error(t_program *program, char *cmd, char *s, char *message)
{
program->flag_identifier = 1;
program->status = 1;
write(2, cmd, ft_strlen(cmd));
write(2, ":", 1);
write(2, "`", 1);
write(2, s, ft_strlen(s));
write(2, "'", 1);
write(2, message, ft_strlen(message));
write(2, "\n", 1);
}
void free_path(t_program *program)
{
free_array(program->sep_path);
free_array(program->env_cmd);
exec_error(program, " command not found", 127);
}