|
|
@ -27,7 +27,7 @@ int builtin_call(t_datas *datas, t_command *cmd) |
|
|
|
else if (ft_strncmp(cmd->argv[0], "env", 4) == 0) |
|
|
|
return (ft_env(datas, cmd)); |
|
|
|
else if (ft_strncmp(cmd->argv[0], "exit", 5) == 0) |
|
|
|
return (close_minishell(0)); |
|
|
|
return (ft_exit(cmd)); |
|
|
|
else |
|
|
|
return (-1); |
|
|
|
} |
|
|
@ -54,19 +54,17 @@ void exe(t_datas *datas, t_command *cmd) |
|
|
|
|
|
|
|
if (ft_strchr(cmd->argv[0], '/')) |
|
|
|
execve(cmd->argv[0], cmd->argv, datas->envp); |
|
|
|
else |
|
|
|
path_dirs = ft_split(getenv("PATH"), ':'); |
|
|
|
while (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); |
|
|
|
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++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|