commit
916194163b
10 changed files with 22 additions and 26 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/21 16:32:26 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/22 17:22:55 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:09:44 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
int fd_replace(int fd1, int fd2)
|
||||
{
|
||||
DG("%i ----> %i", fd2, fd1);
|
||||
if (fd1 != fd2)
|
||||
return (dup2_close(fd1, fd2));
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/22 21:48:12 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:14:08 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -43,6 +43,7 @@ int exec_leaf(t_btree **ast)
|
|||
job_addprocess(&p);
|
||||
if (IS_PIPEEND(p))
|
||||
{
|
||||
DG("end of pipe");
|
||||
if (JOB_IS_FG(job->attrs))
|
||||
put_job_in_foreground(job, 0);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 18:23:49 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 18:41:14 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ int exec_reset(void)
|
|||
jobc = &data_singleton()->jobc;
|
||||
i = -1;
|
||||
while (++i < 10)
|
||||
exec->fd_save[i] = fcntl(i, F_DUPFD, 10);
|
||||
exec->fd_save[i] = fcntl(i, F_DUPFD_CLOEXEC, 10);
|
||||
exec->op_stack = NULL;
|
||||
exec->fdin = STDIN;
|
||||
exec->attrs = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/24 19:43:40 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:44:30 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,6 +21,7 @@ int exec_var(t_btree **ast)
|
|||
char *equal;
|
||||
|
||||
node = (*ast)->item;
|
||||
pop(&data_singleton()->exec.op_stack);
|
||||
if (!(av = token_to_argv(node->data.cmd.token, 1)))
|
||||
return (0);
|
||||
var = av[0];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 18:22:16 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:21:07 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,10 +41,7 @@ int process_launch(t_process *p)
|
|||
if (process_redirect(p))
|
||||
set_exitstatus(1, 1);
|
||||
else
|
||||
{
|
||||
exec_reset();
|
||||
p->map.launch(p);
|
||||
}
|
||||
shell_resetfds();
|
||||
shell_resetsig();
|
||||
process_free(p, 0);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/22 18:26:37 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:19:34 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ int process_set(t_process *p, t_btree *ast)
|
|||
p->pid = 0;
|
||||
exec->fdin = fds[PIPE_READ];
|
||||
if (ast)
|
||||
p->redirs = ft_lstmap(((t_astnode *)ast->item)->data.cmd.redir,
|
||||
&redir_copy);
|
||||
p->redirs = ft_lstmap(
|
||||
((t_astnode *)ast->item)->data.cmd.redir, &redir_copy);
|
||||
return ((!ast) ? 0 : process_set_spec(p, ast));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 18:17:02 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 18:48:46 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -67,7 +67,10 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[])
|
|||
(void)path;
|
||||
(void)envp;
|
||||
if (!SH_HAS_JOBC(data_singleton()->opts))
|
||||
{
|
||||
DG("no job control :(");
|
||||
return (SH_ERR("jobs: %s", SH_MSG_NOJOBC));
|
||||
}
|
||||
do_job_notification();
|
||||
ft_bzero(&data, sizeof(t_data_template));
|
||||
if (cliopts_get((char**)av, g_jobs_opts, &data))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 18:59:40 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:23:12 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,9 +18,8 @@ void token_print(t_list *lst)
|
|||
|
||||
while (lst)
|
||||
{
|
||||
if (lst->content)
|
||||
token = lst->content;
|
||||
DG("%s", read_state(token->type));
|
||||
if ((token = lst->content))
|
||||
DG("token : %s data [%s]", read_state(token->type), token->data);
|
||||
lst = lst->next;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/24 19:18:27 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 19:23:34 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -46,15 +46,12 @@ static int handle_instruction(t_list **token, t_btree **ast)
|
|||
return (ret);
|
||||
if (do_lexer_routine(token, stream) > 0)
|
||||
continue ;
|
||||
token_print(*token);
|
||||
if ((ret = do_parser_routine(token, ast)) == 1
|
||||
&& SH_NO_INTERACTIVE(data->opts))
|
||||
return (ret);
|
||||
else if (ret > 0)
|
||||
break ;
|
||||
}
|
||||
/* btree_print(3, *ast, ft_putast); */
|
||||
/* exit(1); */
|
||||
if (data->parser.state == SUCCESS && ft_exec(ast) < 0)
|
||||
exit(1);
|
||||
else if (data->parser.state != SUCCESS)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 17:11:20 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/24 18:57:17 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -87,10 +87,7 @@ int shell_init(int ac, char **av, char **env)
|
|||
if (data_init(ac, av, env) < 0)
|
||||
return (-1);
|
||||
if (cliopts_get(av, g_opts, data))
|
||||
{
|
||||
ft_perror(NULL);
|
||||
return (SH_ERR("usage: %s", SHELL_USAGE));
|
||||
}
|
||||
return (ft_perror(NULL) && SH_ERR("usage: %s", SHELL_USAGE));
|
||||
if (!isatty(STDIN) || *data->av_data)
|
||||
data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC);
|
||||
if ((data->fd = get_input_fd(data, NULL)) < 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue