|
@ -6,26 +6,26 @@ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ |
|
|
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ |
|
|
/* Updated: 2022/05/03 13:57:06 by narnaud ### ########.fr */ |
|
|
/* Updated: 2022/05/03 20:29:01 by narnaud ### ########.fr */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
|
|
#include "minishell.h" |
|
|
#include "minishell.h" |
|
|
/*
|
|
|
|
|
|
int command_call(char *argv[], int input_fd, int output_fd) |
|
|
int command_call(char *argv[]) |
|
|
{ |
|
|
{ |
|
|
if (ft_strncmp(argv[0], "echo", 4) == 0) |
|
|
if (ft_strncmp(argv[0], "echo", 4) == 0) |
|
|
return (ft_echo(argv, output_fd)); |
|
|
return (ft_echo(argv)); |
|
|
else if (ft_strncmp(argv[0], "pwd", 3) == 0) |
|
|
else if (ft_strncmp(argv[0], "pwd", 3) == 0) |
|
|
return (ft_pwd(argv, input_fd, output_fd)); |
|
|
return (ft_pwd(argv)); |
|
|
else if (ft_strncmp(argv[0], "cd", 2) == 0) |
|
|
else if (ft_strncmp(argv[0], "cd", 2) == 0) |
|
|
return (ft_cd(argv, input_fd, output_fd)); |
|
|
return (ft_cd(argv)); |
|
|
else if (ft_strncmp(argv[0], "export", 6) == 0) |
|
|
else if (ft_strncmp(argv[0], "export", 6) == 0) |
|
|
return (ft_export(argv, input_fd, output_fd)); |
|
|
return (ft_export(argv)); |
|
|
else if (ft_strncmp(argv[0], "unset", 5) == 0) |
|
|
else if (ft_strncmp(argv[0], "unset", 5) == 0) |
|
|
return (ft_unset(argv, input_fd, output_fd)); |
|
|
return (ft_unset(argv)); |
|
|
else if (ft_strncmp(argv[0], "env", 3) == 0) |
|
|
else if (ft_strncmp(argv[0], "env", 3) == 0) |
|
|
return (ft_env(argv, input_fd, output_fd)); |
|
|
return (ft_env(argv)); |
|
|
else if (ft_strncmp(argv[0], "exit", 4) == 0) |
|
|
else if (ft_strncmp(argv[0], "exit", 4) == 0) |
|
|
return (close_minishell(0)); |
|
|
return (close_minishell(0)); |
|
|
else |
|
|
else |
|
@ -34,14 +34,13 @@ int command_call(char *argv[], int input_fd, int output_fd) |
|
|
return (-1); |
|
|
return (-1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
*/ |
|
|
|
|
|
void exe(char *argv[], char *const envp[]) |
|
|
void exe(char *argv[], char *const envp[]) |
|
|
{ |
|
|
{ |
|
|
char **path_dirs; |
|
|
char **path_dirs; |
|
|
char *path; |
|
|
char *path; |
|
|
size_t path_length; |
|
|
size_t path_length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
execve(argv[0], argv, envp); |
|
|
execve(argv[0], argv, envp); |
|
|
path_dirs = ft_split(getenv("PATH"), ':'); |
|
|
path_dirs = ft_split(getenv("PATH"), ':'); |
|
|
while (path_dirs) |
|
|
while (path_dirs) |
|
|