diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_e_lcom.c | 9 | ||||
-rw-r--r-- | src/ft_s_lcom.c | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c index e8787da..acfc187 100644 --- a/src/ft_e_lcom.c +++ b/src/ft_e_lcom.c @@ -13,6 +13,8 @@ #include <libft.h> #include <stdint.h> #include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> #include "ft_s_struct.h" static uint8_t @@ -32,6 +34,7 @@ static uint8_t uint8_t ft_e_lcom(t_msh *msh) { + int fd; t_lcom *ptr; uint8_t bu_id; @@ -41,7 +44,13 @@ uint8_t if ((bu_id = ft_get_builtin_id(ptr->com, msh)) < FT_BUILTINS_COUNT) { + if (ptr->redir == 1 && + (fd = open(ptr->rdrpath, O_CREAT | O_WRONLY, 0644))) + { + dup2(fd, STDOUT_FILENO); + } msh->ret = msh->bu_ptr[bu_id](ptr->args, msh); + close(fd); } else { diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c index b31f5e5..029a5c4 100644 --- a/src/ft_s_lcom.c +++ b/src/ft_s_lcom.c @@ -30,6 +30,7 @@ static int8_t ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1); while(words[i + 1]) { + /* TODO: better <> cut ex: "msh ~> echo qwe>qwe" | gl hf */ if (ft_ischarset("<>", words[i + 1][0])) break ; i++; |