pull ok
This commit is contained in:
commit
5c6abae6dc
17 changed files with 40 additions and 35 deletions
|
|
@ -23,7 +23,7 @@
|
|||
| TK_DO | TK_IF | TK_FI | TK_THEN | TK_ELIF | TK_ELSE)
|
||||
enum e_lexstate
|
||||
{
|
||||
DEFAULT,
|
||||
DEFAULT, //#define DEFAULT 0
|
||||
PAREN,
|
||||
HEREDOC,
|
||||
NEWLINE,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ void c_printer(t_comp *c)
|
|||
t_clst *ptr;
|
||||
int loop;
|
||||
int max_line;
|
||||
int offset;
|
||||
//int offset;
|
||||
|
||||
loop = c->c_line;
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ void c_printer(t_comp *c)
|
|||
max_line = (c->c_line % (c->m_size - 1));
|
||||
else
|
||||
max_line = c->m_size - 1;
|
||||
offset = (c->m_size - 1) - max_line;
|
||||
// offset = (c->m_size - 1) - max_line;
|
||||
while (loop && max_line)
|
||||
{
|
||||
c_printer_line(c, ptr, c->c_pline, 1);
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ int exec_leaf(t_btree **ast)
|
|||
return (1);
|
||||
if (!(launch_process(&p)))
|
||||
{
|
||||
DG("forked pid=[%i], name=[%s]", p.pid, p.data.cmd.av[0]);
|
||||
/* DG("forked pid=[%i], name=[%s]", p.pid, p.data.cmd.av[0]); */
|
||||
job_addprocess(&p);
|
||||
DG("[IS_BG->%i]", JOB_IS_BG(job->attrs));
|
||||
/* DG("[IS_BG->%i]", JOB_IS_BG(job->attrs)); */
|
||||
if (IS_PIPEEND(p))
|
||||
{
|
||||
if (JOB_IS_FG(job->attrs))
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ int launch_file(t_process *p)
|
|||
{
|
||||
/* data_singleton()->opts &= ~SH_INTERACTIVE; */
|
||||
/* data_singleton()->opts &= ~SH_OPTS_JOBC; */
|
||||
DG("fork! [%s]", p->data.cmd.av[0]);
|
||||
/* DG("fork! [%s]", p->data.cmd.av[0]); */
|
||||
process_setgroup(p, 0);
|
||||
process_setsig();
|
||||
if (process_redirect(p))
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ int launch_process(t_process *p)
|
|||
{
|
||||
int pid;
|
||||
|
||||
DG("launchprocess");
|
||||
if (p->type >= PROCESS_MAX)
|
||||
return (-1);
|
||||
if (!g_launchmap[p->type].f)
|
||||
|
|
@ -38,7 +37,6 @@ int launch_process(t_process *p)
|
|||
p->attrs |= PROCESS_RUNNING;
|
||||
if (!(pid = (*g_launchmap[p->type].f)(p)))
|
||||
{
|
||||
DG("gonna reset fds");
|
||||
process_resetfds(p);
|
||||
return (1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,14 @@
|
|||
|
||||
static int do_subshell(t_process *p)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ft_exec(&p->data.subshell.content);
|
||||
ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
DG("CHECK, ret=[%i]", ret);
|
||||
/* p = ft_lstlast(j->first_process)->content; */
|
||||
/* ret = p->status */
|
||||
/* DG("CHECK, ret=[%i]", ret); */
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ int mark_process_status(pid_t pid, int status)
|
|||
{
|
||||
p = plist->content;
|
||||
p->status = status;
|
||||
DG("marking pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]);
|
||||
/* DG("found pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]); */
|
||||
if (WIFSTOPPED(status))
|
||||
{
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int process_redirect(t_process *p)
|
|||
{
|
||||
redir = redirs->content;
|
||||
DG("redirs content : %p", redirs->content);
|
||||
DG("redir.type [%i]", redir->type);
|
||||
// DG("redir.type [%li]", redir->type);
|
||||
DG("redir.word [%s]", redir->word);
|
||||
DG("redir.n [%i]", redir->n);
|
||||
if (redir->n > 9)
|
||||
|
|
|
|||
|
|
@ -21,13 +21,16 @@ int process_setgroup(t_process *p, pid_t pid)
|
|||
(void)p;
|
||||
data = data_singleton();
|
||||
j = &data->exec.job;
|
||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
return (0);
|
||||
DG("setpgid(%i, %i)", pid, j->pgid);
|
||||
if (setpgid(pid, j->pgid) == -1)
|
||||
ft_dprintf(2, "{red}%s: internal setpgid() error{eoc}\n", SHELL_NAME);
|
||||
if (pid == 0 && JOB_IS_FG(j->attrs))
|
||||
{
|
||||
DG("I'm taking the terminal !");
|
||||
DG("tcsetpgrp[%i]", j->pgid);
|
||||
tcsetpgrp(STDIN, j->pgid);
|
||||
DG("after tcsetpgrp");
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,5 +19,7 @@ void process_setsig(void)
|
|||
signal(SIGTSTP, SIG_DFL);
|
||||
signal(SIGTTIN, SIG_DFL);
|
||||
signal(SIGTTOU, SIG_DFL);
|
||||
/* signal(SIGTTIN, sigttin_handler); */
|
||||
/* signal(SIGTTOU, sigttou_handler); */
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ int dir_research(t_glob *gl, char *p,
|
|||
ft_ld_pushfront(&gl->match_tmp, ft_strjoin(p + gl->cur_dir * 2 *
|
||||
(p[0] == '.' && p[1] == '/'), "/"));
|
||||
else
|
||||
ft_ld_pushfront(&gl->match_tmp, ft_strdup(""));
|
||||
ft_ld_pushfront(&gl->match_tmp, ft_strdup(CH(gl->m_pat)[0]));
|
||||
return (0);
|
||||
}
|
||||
if ((ft_strlen(p) <= 1 || p[ft_strlen(p) - 1] != '.') && is_directory(p))
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ int job_addprocess(t_process *p)
|
|||
{
|
||||
job_update_id();
|
||||
job->id = jobc->current_id;
|
||||
/* job->pgid = SH_HAS_JOBC(data_singleton()->opts) ? p->pid : getpid(); */
|
||||
job->pgid = p->pid;
|
||||
job->pgid = SH_IS_INTERACTIVE(data_singleton()->opts) ? p->pid : getpgid(0);
|
||||
/* job->pgid = p->pid; */
|
||||
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
|
||||
}
|
||||
DG("adding pid=[%i] to pgid=[%i]", p->pid, job->pgid);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ void job_remove(int id)
|
|||
if (job_is_completed(id))
|
||||
{
|
||||
p = ft_lstlast(j->first_process)->content;
|
||||
/* DG("remove, status=%i", p->status); */
|
||||
set_exitstatus(p->status, 0);
|
||||
if (id < data_singleton()->jobc.current_id)
|
||||
data_singleton()->jobc.current_id = id;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ int put_job_in_foreground(t_job *j, int cont)
|
|||
t_jobc *jobc;
|
||||
|
||||
jobc = &data_singleton()->jobc;
|
||||
DG("giving terminal to pgid->[%i]", j->pgid);
|
||||
tcsetpgrp(STDIN, j->pgid);
|
||||
|
||||
DG("tcsetpgrp[%i]", j->pgid);
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
tcsetpgrp(STDIN, j->pgid);
|
||||
if (cont)
|
||||
{
|
||||
tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
|
||||
|
|
@ -28,8 +28,7 @@ int put_job_in_foreground(t_job *j, int cont)
|
|||
}
|
||||
job_wait(j->id);
|
||||
job_remove(j->id);
|
||||
|
||||
if (SH_HAS_JOBC(data_singleton()->opts))
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
{
|
||||
tcsetpgrp(STDIN, jobc->shell_pgid);
|
||||
tcgetattr(STDIN, &j->tmodes);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/11 20:05:07 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/13 14:08:29 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -124,7 +124,6 @@ int main(int ac, char **av)
|
|||
DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
||||
while (handle_instruction(fd) == 0)
|
||||
{
|
||||
DG();
|
||||
// lexer_clean;
|
||||
// parser_clean;
|
||||
;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
int iscondition(t_btree **ast, t_list **lst)
|
||||
{
|
||||
t_astnode *node;
|
||||
t_token *token;
|
||||
// t_token *token;
|
||||
|
||||
node = NULL;
|
||||
token = (*lst)->content;
|
||||
// token = (*lst)->content;
|
||||
if (*ast)
|
||||
{
|
||||
node = (*ast)->item;
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/11 14:54:18 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/11 20:05:41 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/13 14:08:09 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
static int isdir_sep_condition(t_btree **ast, t_list **lst)
|
||||
static int isdir_sep_condition(t_btree **ast)//, t_list **lst)
|
||||
{
|
||||
t_token *token;
|
||||
// t_token *token;
|
||||
t_astnode *node;
|
||||
|
||||
token = (*lst)->content;
|
||||
// token = (*lst)->content;
|
||||
if (*ast)
|
||||
{
|
||||
node = (*ast)->item;
|
||||
|
|
@ -27,12 +27,12 @@ static int isdir_sep_condition(t_btree **ast, t_list **lst)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int isdir_word_condition(t_btree **ast, t_list **lst)
|
||||
static int isdir_word_condition(t_btree **ast)//, t_list **lst)
|
||||
{
|
||||
t_token *token;
|
||||
// t_token *token;
|
||||
t_astnode *node;
|
||||
|
||||
token = (*lst)->content;
|
||||
// token = (*lst)->content;
|
||||
if (*ast)
|
||||
{
|
||||
node = (*ast)->item;
|
||||
|
|
@ -45,19 +45,19 @@ static int isdir_word_condition(t_btree **ast, t_list **lst)
|
|||
int isdir_condition(t_btree **ast, t_list **lst)
|
||||
{
|
||||
t_token *token;
|
||||
t_astnode *node;
|
||||
// t_astnode *node;
|
||||
|
||||
token = (*lst)->content;
|
||||
if (*ast)
|
||||
{
|
||||
node = (*ast)->item;
|
||||
// node = (*ast)->item;
|
||||
if ((token->type == TK_LESS || token->type == TK_GREAT
|
||||
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|
||||
|| token->type == TK_DLESS || token->type == TK_DGREAT)
|
||||
&& isdir_sep_condition(&(*ast)->left, lst) == 1)
|
||||
&& isdir_sep_condition(&(*ast)->left) == 1)
|
||||
return (1);
|
||||
if (token->type == TK_WORD
|
||||
&& isdir_word_condition(&(*ast)->left, lst) == 1)
|
||||
&& isdir_word_condition(&(*ast)->left) == 1)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue