From 8ae69101226e1758f9aa72f2b4cd674a49cdee4a Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 7 Feb 2017 12:03:22 +0100 Subject: [PATCH] redirection of identical fds does nothing --- 42sh/src/exec/process_redirect.c | 2 +- 42sh/src/exec/redirect_greatand.c | 4 +++- 42sh/src/exec/redirect_lessand.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/42sh/src/exec/process_redirect.c b/42sh/src/exec/process_redirect.c index 925a6b92..dfe8615b 100644 --- a/42sh/src/exec/process_redirect.c +++ b/42sh/src/exec/process_redirect.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ -/* Updated: 2017/02/06 22:23:33 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:01:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redirect_greatand.c b/42sh/src/exec/redirect_greatand.c index 1dd2fb4e..10abaa48 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/02/06 22:54:20 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:01:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,8 @@ int redirect_greatand(t_redir *redir) int fdold; int fdnew; + if (redir->word.fd == redir->n) + return (0); if (redir->word.fd > 9) bad_fd(redir->word.fd); if (redir->close) diff --git a/42sh/src/exec/redirect_lessand.c b/42sh/src/exec/redirect_lessand.c index 6109abe1..fa4450b9 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/02/06 22:55:03 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:01:56 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,8 @@ int redirect_lessand(t_redir *redir) int fdold; int fdnew; + if (redir->word.fd == redir->n) + return (0); if (redir->word.fd > 9) bad_fd(redir->word.fd); if (redir->close)