fix: use builtin
This commit is contained in:
parent
96de7639cd
commit
255892e12e
BIN
.execution.c.swp
Normal file
BIN
.execution.c.swp
Normal file
Binary file not shown.
34
execution.c
34
execution.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
|
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/21 13:48:39 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/21 15:06:12 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -95,21 +95,25 @@ static int ft_excutor(t_cmd *cmd, t_list **env)
|
|||||||
|
|
||||||
static int ft_own_cmd(t_list **env, t_cmd *cmd)
|
static int ft_own_cmd(t_list **env, t_cmd *cmd)
|
||||||
{
|
{
|
||||||
/* if (ft_strcmp(cmd->executable, "pwd") == 0) */
|
int return_code;
|
||||||
/* return (pwd(env, cmd->fd_out)); */
|
|
||||||
if (ft_strcmp(cmd->executable, "env") == 0)
|
return_code = -1;
|
||||||
return (print_env(env, cmd->fd_out));
|
if (ft_strcmp(cmd->executable, "pwd") == 0)
|
||||||
if (ft_strcmp(cmd->executable, "export") == 0)
|
return_code = pwd(cmd->fd_out);
|
||||||
return (print_export(env, cmd->fd_out));
|
else if (ft_strcmp(cmd->executable, "env") == 0)
|
||||||
/* if (ft_strcmp(cmd->executable, "cd") == 0) */
|
return_code = print_env(env, cmd->fd_out);
|
||||||
/* return (move_folder(cmd->args[0], cmd->fd_out)); */
|
else if (ft_strcmp(cmd->executable, "export") == 0)
|
||||||
|
return_code = (print_export(env, cmd->fd_out));
|
||||||
|
else if (ft_strcmp(cmd->executable, "cd") == 0)
|
||||||
|
return_code = (move_folder(cmd->args[0], cmd->fd_out));
|
||||||
/* if (ft_strcmp(cmd->executable, "unset") == 0) */
|
/* if (ft_strcmp(cmd->executable, "unset") == 0) */
|
||||||
/* return (unset(env, cmd->args, cmd->fd_out)); */
|
/* return_code = (unset(env, cmd->args, cmd->fd_out)); */
|
||||||
/* if (ft_strcmp(cmd->executable, "echo") == 0) */
|
else if (ft_strcmp(cmd->executable, "echo") == 0)
|
||||||
/* return (echo(cmd->fd_out, cmd->args[0])); */
|
return_code = (echo(cmd->fd_out, cmd->args + 1));
|
||||||
if (ft_strcmp(cmd->executable, "exit") == 0)
|
else if (ft_strcmp(cmd->executable, "exit") == 0)
|
||||||
return (-2);
|
return_code = -2;
|
||||||
return (-1);
|
cmd->executable = NULL;
|
||||||
|
return (return_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ft_cmds_executor(t_list **cmds, t_list **env)
|
int ft_cmds_executor(t_list **cmds, t_list **env)
|
||||||
|
9
main.c
9
main.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
|
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/21 14:24:45 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/21 14:48:07 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,8 +17,13 @@ static char *ft_get_user_input(t_list **env)
|
|||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
|
char *pwd;
|
||||||
|
|
||||||
prompt = ft_strmerger(2, get_value_by_key("PWD", env), "$ ");
|
pwd = get_pwd(2);
|
||||||
|
if (pwd == NULL)
|
||||||
|
return (NULL);
|
||||||
|
prompt = ft_strmerger(2, pwd, "$ ");
|
||||||
|
free(pwd);
|
||||||
if (prompt == NULL)
|
if (prompt == NULL)
|
||||||
{
|
{
|
||||||
ft_eprintf("minishell: malloc failed\n");
|
ft_eprintf("minishell: malloc failed\n");
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/21 14:43:45 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/21 15:05:50 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ char *get_value(char *str);
|
|||||||
char *get_key(char *str);
|
char *get_key(char *str);
|
||||||
|
|
||||||
/* Echo */
|
/* Echo */
|
||||||
int echo(int fd, char *str);
|
int echo(int fd, char **args);
|
||||||
/* PWD */
|
/* PWD */
|
||||||
int pwd(int fd);
|
int pwd(int fd);
|
||||||
char *get_pwd(int fd);
|
char *get_pwd(int fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user