-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_pwd.c
38 lines (35 loc) · 1.31 KB
/
init_pwd.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_pwd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jnappa <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/05 21:56:55 by jnappa #+# #+# */
/* Updated: 2022/03/05 21:56:56 by jnappa ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void init_pwd(t_enpv *lst)
{
t_enpv *next;
t_enpv *new;
next = lst;
if (ft_get_info(lst, "PWD"))
{
next = get_adress_info(lst, "PWD");
free(next->info);
next->info = getcwd(NULL, 0);
return ;
}
while (next->next)
next = next->next;
new = malloc(sizeof(t_enpv));
if (!new)
return ;
new->name = copy_str("PWD", 0, 3);
new->info = getcwd(NULL, 0);
new->next = NULL;
next->next = new;
new->exp = 1;
}