-
Notifications
You must be signed in to change notification settings - Fork 2
/
list.c
50 lines (47 loc) · 1.67 KB
/
list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* eval/list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alucas- <alucas-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/07 09:52:30 by alucas- #+# #+# */
/* Updated: 2018/01/06 11:10:01 by alucas- ### ########.fr */
/* */
/* ************************************************************************** */
#include "ush/eval.h"
inline int sh_evallist(int fd, t_deq *toks, char **ln)
{
t_tok *tok;
t_job job;
sh_jobctor(&job);
if (sh_evalandor(&job, fd, toks, ln))
return (NOP);
while (1)
if ((tok = sh_tokpeek(toks))->id == TOK_AMP)
{
sh_toknext(toks);
sh_poolpush(&job);
sh_jobctor(&job);
if (sh_evalandor(&job, fd, toks, ln))
return (YEP);
}
else if (tok->id == TOK_SEMICOLON)
{
sh_toknext(toks);
sh_joblaunch(&job, 1);
g_shstatus = job.processes.len ?
job.processes.buf[job.processes.len - 1].status : 0;
job.processes.len = 0;
if (sh_evalandor(&job, fd, toks, ln))
return (YEP);
}
else
{
sh_joblaunch(&job, 1);
g_shstatus = job.processes.len ?
job.processes.buf[job.processes.len - 1].status : 0;
sh_jobdtor(&job);
return (YEP);
}
}