redirect greatand / lessand execution done (parsing not functional yet)

This commit is contained in:
Jack Halford 2017-03-05 19:48:56 +01:00
parent 23cdcb2dbb
commit 40aebb29b2
7 changed files with 30 additions and 34 deletions

View file

@ -161,7 +161,7 @@ struct s_redir
t_flag type;
int n;
char *word;
int close;
/* int close; */
};
struct s_cmd

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */
/* Updated: 2017/02/06 22:54:19 by jhalford ### ########.fr */
/* Updated: 2017/03/05 19:44:16 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:59:06 by jhalford ### ########.fr */
/* Updated: 2017/03/05 19:40:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
/* Updated: 2017/03/05 18:07:25 by ariard ### ########.fr */
/* Updated: 2017/03/05 19:35:02 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
/* Updated: 2017/03/05 18:12:26 by ariard ### ########.fr */
/* Updated: 2017/03/05 19:44:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,26 +17,25 @@ int redirect_greatand(t_redir *redir)
int fdold;
int fdnew;
(void)redir;
(void)fdold;
(void)fdnew;
DG("redir greatand");
/*
if (redir->close)
if (ft_strcmp(redir->word, "-"))
{
close(redir->n);
return (0);
}
if (redir->word.fd == redir->n)
return (0);
if (redir->word.fd > 9)
return (bad_fd(redir->word.fd));
fdold = redir->word.fd;
if (!ft_stris(redir->word, ft_isdigit))
{
ft_dprintf(2, "%s: %s: can only be digits", SHELL_NAME, redir->word);
return (1);
}
fdold = ft_atoi(redir->word);
fdnew = redir->n;
if (fdold == fdnew)
return (0);
if (fdold > 9)
return (bad_fd(fdold));
if (fd_is_valid(fdold))
dup2_close(fdold, fdnew);
else
return (bad_fd(fdold));
*/
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */
/* Updated: 2017/03/05 18:13:11 by ariard ### ########.fr */
/* Updated: 2017/03/05 19:43:42 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,28 +17,25 @@ int redirect_lessand(t_redir *redir)
int fdold;
int fdnew;
(void)redir;
(void)fdold;
(void)fdnew;
/*
if (redir->close)
if (ft_strcmp(redir->word, "-"))
{
close(redir->n);
return (0);
}
if (redir->word.fd == redir->n)
return (0);
if (redir->word.fd > 9)
return (bad_fd(redir->word.fd));
fdold = redir->word.fd;
fdnew = redir->n;
if (fd_is_valid(fdold))
if (!ft_stris(redir->word, ft_isdigit))
{
dup2(fdold, fdnew);
close(fdold);
ft_dprintf(2, "%s: %s: can only be digits", SHELL_NAME, redir->word);
return (1);
}
fdold = ft_atoi(redir->word);
fdnew = redir->n;
if (fdold == fdnew)
return (0);
if (fdold > 9)
return (bad_fd(fdold));
if (fd_is_valid(fdold))
dup2_close(fdold, fdnew);
else
return (bad_fd(fdold));
*/
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */
/* Updated: 2017/03/05 19:30:00 by jhalford ### ########.fr */
/* Updated: 2017/03/05 19:31:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */