-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmds_paths_utils.c
More file actions
executable file
·36 lines (33 loc) · 1.42 KB
/
cmds_paths_utils.c
File metadata and controls
executable file
·36 lines (33 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmds_paths_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hkonte <hkonte@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/29 13:13:55 by hkonte #+# #+# */
/* Updated: 2024/11/29 13:14:27 by hkonte ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void cmds_paths_maker(t_main *main)
{
char *env_value;
int i;
i = 0;
if (main->cmds_paths && main->cmds_paths->paths)
{
while (main->cmds_paths->paths[i])
free(main->cmds_paths->paths[i++]);
free(main->cmds_paths->paths);
}
if (!main->cmds_paths)
main->cmds_paths = ft_calloc(1, sizeof(t_cmds_paths));
env_value = get_env_value(main->envp, "PATH");
if (env_value == NULL)
{
main->cmds_paths->paths = NULL;
return ;
}
main->cmds_paths->paths = ft_split(env_value, ':');
}