summaryrefslogtreecommitdiffstats
path: root/src/ft_e_lcom.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_e_lcom.c9
1 files changed, 9 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
{