-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcd1.c
53 lines (48 loc) · 1.49 KB
/
cd1.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cd1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adel-cor <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/05 11:22:16 by adel-cor #+# #+# */
/* Updated: 2022/04/12 10:21:57 by adel-cor ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int env_compare(char **env, char **arg, int i)
{
char **split;
while (env[i])
{
split = ft_splitc(env[i], '=');
if (ft_strcmp(split[0], arg[0]) == 0)
{
ft_free_tab(split);
break ;
}
i++;
ft_free_tab(split);
}
return (i);
}
char **ms_matrix_add_line(char **matrix, char *new_line)
{
int i;
char **new_matrix;
i = 0;
while (matrix[i])
i++;
new_matrix = malloc(sizeof(char *) * (i + 2));
i = 0;
while (matrix[i])
{
new_matrix[i] = ft_strdup(matrix[i]);
i++;
}
new_matrix[i] = ft_strdup(new_line);
i++;
new_matrix[i] = NULL;
ft_free_tab(matrix);
return (new_matrix);
}