|
|
@ -54,17 +54,20 @@ void exe(t_datas *datas, t_command *cmd) |
|
|
|
|
|
|
|
if (ft_strchr(cmd->argv[0], '/')) |
|
|
|
execve(cmd->argv[0], cmd->argv, datas->envp); |
|
|
|
path_dirs = ft_split(getenv("PATH"), ':'); |
|
|
|
while (path_dirs) |
|
|
|
else |
|
|
|
{ |
|
|
|
path_length = ft_strlen(*path_dirs) + ft_strlen(cmd->argv[0]) + 2; |
|
|
|
path = ft_calloc(path_length, sizeof(char)); |
|
|
|
ft_memcpy(path, *path_dirs, ft_strlen(*path_dirs)); |
|
|
|
ft_memcpy(path + ft_strlen(*path_dirs),"/", 1); |
|
|
|
ft_memcpy(path + ft_strlen(*path_dirs) + 1, cmd->argv[0], ft_strlen(cmd->argv[0])); |
|
|
|
execve(path, cmd->argv, datas->envp); |
|
|
|
free(path); |
|
|
|
path_dirs++; |
|
|
|
path_dirs = ft_split(getenv("PATH"), ':'); |
|
|
|
while (path_dirs) |
|
|
|
{ |
|
|
|
path_length = ft_strlen(*path_dirs) + ft_strlen(cmd->argv[0]) + 2; |
|
|
|
path = ft_calloc(path_length, sizeof(char)); |
|
|
|
ft_memcpy(path, *path_dirs, ft_strlen(*path_dirs)); |
|
|
|
ft_memcpy(path + ft_strlen(*path_dirs),"/", 1); |
|
|
|
ft_memcpy(path + ft_strlen(*path_dirs) + 1, cmd->argv[0], ft_strlen(cmd->argv[0])); |
|
|
|
execve(path, cmd->argv, datas->envp); |
|
|
|
free(path); |
|
|
|
path_dirs++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|