From 9f88ed37db59c9c47bc00a3bbce173db22220726 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Wed, 15 Mar 2017 17:50:33 +0100 Subject: [PATCH] issue #92, inversion de O_RDONLY et O_WRONLY pour >& et <& --- 42sh/src/exec/fd_is_valid.c | 2 +- 42sh/src/exec/redirect_greatand.c | 7 +++---- 42sh/src/exec/redirect_lessand.c | 7 +++---- 42sh/src/job-control/job_wait.c | 2 +- 42sh/src/lexer/lexer_lessand.c | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/42sh/src/exec/fd_is_valid.c b/42sh/src/exec/fd_is_valid.c index b0347bcf..41114621 100644 --- a/42sh/src/exec/fd_is_valid.c +++ b/42sh/src/exec/fd_is_valid.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */ -/* Updated: 2017/03/10 13:59:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 17:48:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redirect_greatand.c b/42sh/src/exec/redirect_greatand.c index 8be9aecd..e42cf7eb 100644 --- a/42sh/src/exec/redirect_greatand.c +++ b/42sh/src/exec/redirect_greatand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */ -/* Updated: 2017/03/11 17:32:20 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 17:49:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,10 +33,9 @@ int redirect_greatand(t_redir *redir) return (0); if (fdold > 9) return (bad_fd(fdold)); - if (fd_is_valid(fdold, O_RDONLY | O_RDWR)) + if (fd_is_valid(fdold, O_WRONLY | O_RDWR)) dup2_close(fdold, fdnew); else - close(fdnew); - /* return (bad_fd(fdold)); */ + return (bad_fd(fdold)); return (0); } diff --git a/42sh/src/exec/redirect_lessand.c b/42sh/src/exec/redirect_lessand.c index 30f11cdc..1a5ccf64 100644 --- a/42sh/src/exec/redirect_lessand.c +++ b/42sh/src/exec/redirect_lessand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */ -/* Updated: 2017/03/10 14:00:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 17:49:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,10 +33,9 @@ int redirect_lessand(t_redir *redir) return (0); if (fdold > 9) return (bad_fd(fdold)); - if (fd_is_valid(fdold, O_WRONLY | O_RDWR)) + if (fd_is_valid(fdold, O_RDONLY | O_RDWR)) dup2_close(fdold, fdnew); else - close(fdnew); - /* return (bad_fd(fdold)); */ + return (bad_fd(fdold)); return (0); } diff --git a/42sh/src/job-control/job_wait.c b/42sh/src/job-control/job_wait.c index 3033978a..e1c36928 100644 --- a/42sh/src/job-control/job_wait.c +++ b/42sh/src/job-control/job_wait.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */ -/* Updated: 2017/03/14 23:43:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 17:49:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_lessand.c b/42sh/src/lexer/lexer_lessand.c index 3930c001..e7769130 100644 --- a/42sh/src/lexer/lexer_lessand.c +++ b/42sh/src/lexer/lexer_lessand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:58:51 by jhalford #+# #+# */ -/* Updated: 2017/03/08 12:12:01 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 17:48:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */