"with error from 42shelltester"
This commit is contained in:
Antoine Riard 2017-03-24 17:43:41 +01:00
commit d3324cacd6
18 changed files with 28 additions and 58 deletions

View file

@ -109,9 +109,13 @@ int builtin_read(const char *path, char *const av[], char *const envp[])
if ((ret = bt_read_init(&data, (char **)av)) != 0) if ((ret = bt_read_init(&data, (char **)av)) != 0)
SH_ERR("usage: %s%s", US_READ, US_READ_1); SH_ERR("usage: %s%s", US_READ, US_READ_1);
else if ((ret = bt_read_loop(&data))) else if ((ret = bt_read_loop(&data)))
{
; ;
}
else if (data.input && (ret = bt_read_assign(&data))) else if (data.input && (ret = bt_read_assign(&data)))
{
; ;
}
bt_read_exit(&data); bt_read_exit(&data);
return (ret); return (ret);
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/23 16:25:23 by ariard #+# #+# */ /* Created: 2017/03/23 16:25:23 by ariard #+# #+# */
/* Updated: 2017/03/24 16:36:39 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:22:12 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -45,7 +45,6 @@ int exec_func(t_btree **ast)
t_btree *func_ast; t_btree *func_ast;
t_list *old_func; t_list *old_func;
DG();
func_ast = btree_map(*ast, &node_copy); func_ast = btree_map(*ast, &node_copy);
if ((old_func = is_already_func(&func_ast))) if ((old_func = is_already_func(&func_ast)))
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/24 15:51:24 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:22:18 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -36,7 +36,6 @@ int process_redirect(t_process *p)
fd_replace(p->fdout, STDOUT); fd_replace(p->fdout, STDOUT);
while (redirs) while (redirs)
{ {
DG();
redir = redirs->content; redir = redirs->content;
if (redir->n > 9) if (redir->n > 9)
return (bad_fd(redir->n)); return (bad_fd(redir->n));

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:02:58 by ariard #+# #+# */ /* Created: 2017/03/08 00:02:58 by ariard #+# #+# */
/* Updated: 2017/03/24 15:54:27 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:22:23 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,6 @@ void *redir_copy(void *data)
if (!data) if (!data)
return (NULL); return (NULL);
DG();
old = data; old = data;
new = (t_redir *)ft_memalloc(sizeof(t_redir)); new = (t_redir *)ft_memalloc(sizeof(t_redir));
new->type = old->type; new->type = old->type;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */ /* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
/* Updated: 2017/03/24 15:59:36 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:22:28 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,6 @@ int redirect_great(t_redir *redir)
if ((fdold = open(redir->word, if ((fdold = open(redir->word,
O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
exit(1); exit(1);
DG("%d %d", fdold, fdnew);
dup2(fdold, fdnew); dup2(fdold, fdnew);
return (0); return (0);
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* job_format_head.c :+: :+: :+: */ /* job_format_head.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:10:38 by jhalford #+# #+# */ /* Created: 2017/01/09 13:10:38 by jhalford #+# #+# */
/* Updated: 2017/03/21 14:55:16 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:22:36 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,5 @@ void job_format_head(t_job *j)
job_getrank(&rank); job_getrank(&rank);
crank = j->id == rank[0] ? '+' : ' '; crank = j->id == rank[0] ? '+' : ' ';
crank = j->id == rank[1] ? '-' : crank; crank = j->id == rank[1] ? '-' : crank;
DG("raks [%i:%i]", rank[0], rank[1]);
ft_printf("{mag}[%i]%c {eoc}", j->id, crank); ft_printf("{mag}[%i]%c {eoc}", j->id, crank);
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* job_hup_all.c :+: :+: :+: */ /* job_hup_all.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */ /* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */
/* Updated: 2017/03/24 15:40:55 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:22:42 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,11 +25,9 @@ void job_hup_all(void)
while (jlist) while (jlist)
{ {
job = jlist->content; job = jlist->content;
DG("gonna SIGHUP %i", job->pgid);
builtin_jobs(NULL, NULL, NULL); builtin_jobs(NULL, NULL, NULL);
if (job->pgid != 1) if (job->pgid != 1)
kill(-job->pgid, SIGHUP); kill(-job->pgid, SIGHUP);
DG("after SIGHUP %i", job->pgid);
jlist = jlist->next; jlist = jlist->next;
} }
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:32:56 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:26:50 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,6 +24,7 @@ int put_job_in_foreground(t_job *j, int cont)
tcsetattr(STDIN, TCSADRAIN, &j->tmodes); tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
if (kill(-j->pgid, SIGCONT) < 0) if (kill(-j->pgid, SIGCONT) < 0)
DG("kill(SIGCONT) failed"); DG("kill(SIGCONT) failed");
//msg d'erreur a changer ici
} }
job_wait(j->id); job_wait(j->id);
if (SH_IS_INTERACTIVE(data_singleton()->opts)) if (SH_IS_INTERACTIVE(data_singleton()->opts))

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* sigint_handler.c :+: :+: :+: */ /* sigint_handler.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */ /* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */
/* Updated: 2017/03/22 18:17:42 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:24:18 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,5 +16,4 @@ void sigint_handler(int signo)
{ {
(void)signo; (void)signo;
set_exitstatus(1, 1); set_exitstatus(1, 1);
DG("pid:%i got SIGINT", getpid());
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* sigttin_handler.c :+: :+: :+: */ /* sigttin_handler.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */ /* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
/* Updated: 2017/01/22 17:22:10 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:24:13 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,5 +15,4 @@
void sigttin_handler(int signo) void sigttin_handler(int signo)
{ {
(void)signo; (void)signo;
DG("got SIGTTIN, pid=%i, pgid=%i", getpid(), getpgrp());
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */ /* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
/* Updated: 2017/03/20 10:30:55 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:23:18 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,5 +15,4 @@
void sigttou_handler(int signo) void sigttou_handler(int signo)
{ {
(void)signo; (void)signo;
DG("got SIGTTOU, pid=%i, pgid=%i", getpid(), getpgid(getpid()));
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 20:25:08 by ariard #+# #+# */ /* Created: 2017/03/16 20:25:08 by ariard #+# #+# */
/* Updated: 2017/03/24 17:07:56 by gwojda ### ########.fr */ /* Updated: 2017/03/24 17:15:18 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* token_print.c :+: :+: :+: */ /* token_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */ /* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:13:31 by jhalford ### ########.fr */ /* Updated: 2017/03/24 17:24:09 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,8 +20,6 @@ void token_print(t_list *lst)
{ {
if (lst->content) if (lst->content)
token = lst->content; token = lst->content;
if (token->type)
DG("token : %s data [%s]", read_state(token->type), token->data);
lst = lst->next; lst = lst->next;
} }
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/24 17:11:37 by wescande ### ########.fr */ /* Updated: 2017/03/24 17:24:04 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -66,7 +66,6 @@ int main(int ac, char **av, char **env)
t_btree *ast; t_btree *ast;
g_argv = av; g_argv = av;
DG("----------------");
if (shell_init(ac, av, env) != 0) if (shell_init(ac, av, env) != 0)
return (1); return (1);
token = NULL; token = NULL;

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* add_file.c :+: :+: :+: */ /* add_redir.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */ /* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/03/24 15:55:55 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:24:01 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -71,7 +71,6 @@ int add_redir_word(t_btree **ast, t_list **lst)
token = (*lst)->content; token = (*lst)->content;
node = (*ast)->item; node = (*ast)->item;
DG("node type is %s", read_state(node->type));
if (node->data.cmd.redir) if (node->data.cmd.redir)
{ {
redir = (ft_lstlast(node->data.cmd.redir))->content; redir = (ft_lstlast(node->data.cmd.redir))->content;
@ -112,7 +111,6 @@ int add_redir_type(t_btree **ast, t_list **lst)
gen_node(ast); gen_node(ast);
token = (*lst)->content; token = (*lst)->content;
node = (*ast)->item; node = (*ast)->item;
DG("node type is %s", read_state(node->type));
if (!(node->type == TK_IO_NUMBER)) if (!(node->type == TK_IO_NUMBER))
{ {
redir_init(token->type, &redir); redir_init(token->type, &redir);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/23 16:48:38 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:23:26 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -397,16 +397,3 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
} }
return (0); return (0);
} }
/*
** DG("aggregate head %s && sym %s",
** read_state(*head), read_state(*new_sym));
*/
/*
** DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
*/
/*
** DG("stack after pop: %s", read_state(*head));
*/

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/23 16:48:22 by ariard ### ########.fr */ /* Updated: 2017/03/24 17:23:52 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -1295,7 +1295,3 @@ int eval_sym(t_list **stack, t_sym new_sym)
} }
return (1); return (1);
} }
/*
** DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
*/

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 15:32:10 by ariard #+# #+# */ /* Created: 2017/02/09 15:32:10 by ariard #+# #+# */
/* Updated: 2017/03/20 14:59:23 by gwojda ### ########.fr */ /* Updated: 2017/03/24 17:25:03 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -221,7 +221,6 @@ char *read_state(t_sym current)
int ft_read_stack(t_sym *stack) int ft_read_stack(t_sym *stack)
{ {
DG("read stack :");
while (*stack) while (*stack)
DG("%s", read_state(*stack--)); DG("%s", read_state(*stack--));
return (0); return (0);
@ -236,7 +235,5 @@ int ft_show_heredoc_data(t_astnode *node)
redir = (node->data.cmd.redir)->content; redir = (node->data.cmd.redir)->content;
if (redir->type != TK_DLESS) if (redir->type != TK_DLESS)
return (1); return (1);
DG("heredoc_data=[%s] @ %p", redir->heredoc_data, redir->heredoc_data);
DG("redir @ %p", redir);
return (0); return (0);
} }