diff --git a/42sh/includes/types.h b/42sh/includes/types.h index c2aea9ff..72e30a72 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/02/03 14:02:56 by jhalford ### ########.fr */ +/* Updated: 2017/02/03 14:54:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/process_do_redirection.c b/42sh/src/exec/process_do_redirection.c index dacd34b4..2cb1c02b 100644 --- a/42sh/src/exec/process_do_redirection.c +++ b/42sh/src/exec/process_do_redirection.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */ -/* Updated: 2017/02/03 14:41:01 by jhalford ### ########.fr */ +/* Updated: 2017/02/03 14:55:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ void process_do_redirection(t_redir *redir) { fdin = redir->n; fdout = open(redir->word.word, O_WRONLY | O_CREAT - (redir->type & TK_GREAT) ? O_TRUNC : O_APPEND, + | (redir->type & TK_GREAT) ? O_TRUNC : O_APPEND, 0644); } else if (redir->type & TK_LESS) @@ -47,6 +47,11 @@ void process_do_redirection(t_redir *redir) fdout = redir->type & TK_LESSAND ? redir->n : redir->word.fd; } } + else + { + ft_dprintf(2, "{red}%s: redirection error.", SHELL_NAME); + return ; + } fd_is_valid(fdout) ? dup2(fdout, fdin) : close(fdin); close(fdout); }