diff --git a/.execution.c.swp b/.execution.c.swp new file mode 100644 index 0000000..99fb472 Binary files /dev/null and b/.execution.c.swp differ diff --git a/execution.c b/execution.c index fa73ae0..6bf9281 100644 --- a/execution.c +++ b/execution.c @@ -6,7 +6,7 @@ /* By: cchauvet executable, "pwd") == 0) */ - /* return (pwd(env, cmd->fd_out)); */ - if (ft_strcmp(cmd->executable, "env") == 0) - return (print_env(env, cmd->fd_out)); - if (ft_strcmp(cmd->executable, "export") == 0) - return (print_export(env, cmd->fd_out)); - /* if (ft_strcmp(cmd->executable, "cd") == 0) */ - /* return (move_folder(cmd->args[0], cmd->fd_out)); */ + int return_code; + + return_code = -1; + if (ft_strcmp(cmd->executable, "pwd") == 0) + return_code = pwd(cmd->fd_out); + else if (ft_strcmp(cmd->executable, "env") == 0) + return_code = print_env(env, 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) */ - /* return (unset(env, cmd->args, cmd->fd_out)); */ - /* if (ft_strcmp(cmd->executable, "echo") == 0) */ - /* return (echo(cmd->fd_out, cmd->args[0])); */ - if (ft_strcmp(cmd->executable, "exit") == 0) - return (-2); - return (-1); + /* return_code = (unset(env, cmd->args, cmd->fd_out)); */ + else if (ft_strcmp(cmd->executable, "echo") == 0) + return_code = (echo(cmd->fd_out, cmd->args + 1)); + else if (ft_strcmp(cmd->executable, "exit") == 0) + return_code = -2; + cmd->executable = NULL; + return (return_code); } int ft_cmds_executor(t_list **cmds, t_list **env) diff --git a/main.c b/main.c index b67da56..41e02c6 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: cchauvet