-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexit.c
More file actions
55 lines (48 loc) · 1.64 KB
/
Copy pathexit.c
File metadata and controls
55 lines (48 loc) · 1.64 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cdelicia <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/31 00:37:55 by cdelicia #+# #+# */
/* Updated: 2019/11/11 00:43:14 by cdelicia ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void change_return_env_var(int error, t_main *data)
{
t_env *tmp;
tmp = data->env;
while (tmp)
{
if (ft_strncmp(tmp->key, "?", 1) == 0 &&
ft_strncmp(tmp->key, "?", ft_strlen(tmp->key)) == 0)
{
free(tmp->value);
tmp->value = ft_itoa(error);
return ;
}
tmp = tmp->next;
}
}
void command_not_found(t_main *data)
{
ft_putstr_fd("Command_not_found\n", 2);
change_return_env_var(127, data);
}
void syntax_error(t_main *data)
{
ft_putstr_fd("Syntax error\n", 2);
change_return_env_var(258, data);
}
void no_such_file(t_main *data)
{
ft_putstr_fd("No such file or directory\n", 2);
change_return_env_var(127, data);
}
void permission_denied(t_main *data)
{
ft_putstr_fd("Permission denied\n", 2);
change_return_env_var(126, data);
}