-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.c
More file actions
52 lines (46 loc) · 792 Bytes
/
Copy patherror.c
File metadata and controls
52 lines (46 loc) · 792 Bytes
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
/*
** error.c for in /home/sepret_f/PSU_2015_minishell1
**
** Made by fabrice sepret
** Login <sepret_f@epitech.net>
**
** Started on Thu Jan 21 11:30:47 2016 fabrice sepret
** Last update Mon Apr 4 15:15:19 2016 fabrice sepret
*/
#include <stdlib.h>
int my_putchar_error(char c)
{
write(2, &c, 1);
}
int my_putstr_error(char *str)
{
int i;
i = 0;
while (str[i] != 0)
{
if (str[i] == '\\' && str[i + 1] == 'n')
{
my_putchar('\n');
i += 2;
}
my_putchar_error(str[i]);
i += 1;
}
}
int my_exit(char *s)
{
my_putstr_error("exit\n");
if (s != NULL)
exit(my_atoi(s));
else
exit(0);
}
int check_env(char **environ)
{
if (environ[0] == 0)
{
my_putstr_error("ENV is empty\n");
exit (-1);
}
my_putstr("$> ");
}