-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_path2.c
More file actions
45 lines (42 loc) · 1.53 KB
/
command_path2.c
File metadata and controls
45 lines (42 loc) · 1.53 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
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* command_path2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aouchaad <aouchaad@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/22 14:23:10 by aouchaad #+# #+# */
/* Updated: 2023/06/22 14:24:08 by aouchaad ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void look_for_path(t_environment_path **tmp, t_variables *var, char ***paths)
{
while (*tmp)
{
if (ft_strcmp((*tmp)->variable, "PATH") == 0)
{
if ((*tmp)->valeur && (*tmp)->valeur[0] != '\0')
{
var->path_exist = 1;
(*tmp)->valeur = path_error((*tmp)->valeur);
}
(*paths) = ft_split(ft_strdup((*tmp)->valeur), ':');
break ;
}
(*tmp) = (*tmp)->next;
}
}
void is_der_or_isnt_reg(char *command, struct stat file_state)
{
if (S_ISDIR(file_state.st_mode))
{
print_error(command, "is a directory");
exit (126);
}
if (!S_ISREG(file_state.st_mode))
{
print_error(command, strerror(errno));
exit (127);
}
}