-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.c
44 lines (41 loc) · 1.39 KB
/
env.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* env.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wonyang <wonyang@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/09 12:40:20 by wonyang #+# #+# */
/* Updated: 2023/01/15 15:52:52 by wonyang ### ########seoul.kr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include "return.h"
#include "ds_envp.h"
#include "libft.h"
int ft_env(char **argv, t_envp *envp)
{
char **arr;
int i;
if (!argv || !(*argv))
{
printf("ft_env argument error!\n");
return (1);
}
if (argv[1])
{
ft_putstr_fd("env: ", STDERR_FILENO);
ft_putstr_fd(argv[1], STDERR_FILENO);
ft_putendl_fd(": No such file or directory", STDERR_FILENO);
return (127);
}
arr = envp->arr;
i = 0;
while (arr[i])
{
ft_putendl_fd(arr[i], STDOUT_FILENO);
i++;
}
return (0);
}