reading from files now works

This commit is contained in:
Jack Halford 2017-03-03 19:47:06 +01:00
parent 8b88d41ed9
commit f62ef4d9c0
10 changed files with 23 additions and 21 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:01:30 by jhalford #+# #+# */
/* Updated: 2017/03/03 16:05:30 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:35:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,12 +16,13 @@ int exec_ampersand(t_btree **ast)
{
t_exec *exec;
if (!SH_HAS_JOBC(data_singleton()->opts))
return (exec_semi(ast));
exec = &data_singleton()->exec;
push(&exec->op_stack, TK_AMP);
ft_exec(&(*ast)->left);
exec->attrs &= ~EXEC_BG;
ft_exec(&(*ast)->right);
/* if (SH_HAS_JOBC(data_singleton()->opts)) */
/* data_singleton()->exec.job.attributes |= JOB_BG; */
/* ft_exec(&(*ast)->left); */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
/* Updated: 2017/03/03 19:02:44 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:46:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -54,10 +54,7 @@ int exec_cmd(t_btree **ast)
if (op == TK_AMP)
exec->attrs |= JOB_BG;
else if (op == TK_PIPE)
{
pipe(fds);
DG("%i -> PIPE -> %i", fds[PIPE_WRITE], fds[PIPE_READ]);
}
p.fdin = exec->fdin;
p.to_close = fds[PIPE_READ];
p.fdout = fds[PIPE_WRITE];

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/02 20:44:21 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:54:10 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:33:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/31 15:07:30 by jhalford #+# #+# */
/* Updated: 2017/03/03 19:03:01 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:42:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:54:18 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:42:12 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:57:58 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:46:03 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,12 +16,10 @@ int put_job_in_foreground(t_job *j, int cont)
{
t_jobc *jobc;
jobc = &data_singleton()->jobc;
if (SH_HAS_JOBC(data_singleton()->opts))
{
jobc = &data_singleton()->jobc;
tcsetpgrp(STDIN, j->pgid);
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
if (cont)
{
tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
@ -35,9 +33,11 @@ int put_job_in_foreground(t_job *j, int cont)
tcgetattr(STDIN, &j->tmodes);
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
}
else
{
job_wait(j->id);
job_remove(j->id);
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:55:05 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:45:05 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ int data_init(void)
data = data_singleton();
data->env = ft_sstrdup(environ);
data->comp = NULL;
data->opts = SH_OPTS_JOBC;
data->opts = 0;
/* data->exec.process.path = NULL; */
/* data->exec.process.av = NULL; */
/* data->exec.process.to_close = 0; */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/03 19:05:22 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:37:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -98,7 +98,8 @@ int get_input_fd()
}
else if ((file = shell_get_avdata()))
{
if (fd = open(file, O_RDONLY))
if ((fd = open(file, O_RDONLY | O_CLOEXEC)) < 0)
return (-1);
return (fd);
}
else
@ -113,7 +114,7 @@ int main(int ac, char **av)
shell_init(ac, av);
if ((fd = get_input_fd()) < 0)
{
ft_printf("{red}%s: No such file or directory\n{eoc}", SHELL_NAME);
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
return (1);
}
DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s, fd=[%i]",

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/11 14:04:48 by jhalford #+# #+# */
/* Updated: 2017/02/21 15:37:22 by ariard ### ########.fr */
/* Updated: 2017/03/03 19:45:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,10 @@ void shell_get_opts(int ac, char **av)
i = 1;
if (isatty(STDIN) && !av[1])
{
data_singleton()->opts |= SH_INTERACTIVE;
data_singleton()->opts |= SH_OPTS_JOBC;
}
while (i < ac && av[i][0] == '-')
{
if (ft_strcmp(av[i], "--") == 0)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/02 20:38:23 by jhalford ### ########.fr */
/* Updated: 2017/03/03 19:45:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */