diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 20:13:04 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 20:13:04 +0200 |
commit | 2274253667db7bb8c52440ec1b79d6106482b44b (patch) | |
tree | e3ca092c988656596113826ab667e8c07621e7e1 /src/ft_e_builtins.c | |
parent | I am happy (diff) | |
download | 42-minishell-2274253667db7bb8c52440ec1b79d6106482b44b.tar.gz 42-minishell-2274253667db7bb8c52440ec1b79d6106482b44b.tar.bz2 42-minishell-2274253667db7bb8c52440ec1b79d6106482b44b.tar.xz 42-minishell-2274253667db7bb8c52440ec1b79d6106482b44b.tar.zst 42-minishell-2274253667db7bb8c52440ec1b79d6106482b44b.zip |
Not bad tbh
Diffstat (limited to '')
-rw-r--r-- | src/ft_e_builtins.c | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/ft_e_builtins.c b/src/ft_e_builtins.c index d32fbaa..bc3eece 100644 --- a/src/ft_e_builtins.c +++ b/src/ft_e_builtins.c @@ -14,46 +14,14 @@ #include <libft.h> #include <stdlib.h> #include <stdint.h> -#include <fcntl.h> #include <unistd.h> -#include <errno.h> -#include "ft_f_file.h" +#include "ft_m_redirs.h" #include "ft_s_destroy.h" #include "ft_s_lcom.h" #include "ft_s_struct.h" static void - ft_dup_redirs(const t_lcom *ptr, - t_msh *msh) -{ - int32_t fd; - - if (ptr->redir == -1) - { - if ((fd = open(ptr->rdrpath, O_RDONLY)) == -1) - ft_f_file(ptr->rdrpath, msh); - /* TODO: handle < redir */ - } - if (ptr->redir == 1) - { - if ((fd = open(ptr->rdrpath, - O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) - ft_f_file(ptr->rdrpath, msh); - dup2(fd, STDOUT_FILENO); - close(fd); - } - if (ptr->redir == 2) - { - if ((fd = open(ptr->rdrpath, - O_CREAT | O_APPEND | O_WRONLY, 0644)) == -1) - ft_f_file(ptr->rdrpath, msh); - dup2(fd, STDOUT_FILENO); - close(fd); - } -} - -static void ft_e_builtin_child(const t_lcom *ptr, uint8_t bu_id, t_msh *msh) |