From 9aab4ace12a04d0c5477909e54bb43fefcd19f9c Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 17 Jun 2020 17:10:46 +0200 Subject: Added (basic) operator evaluation --- src/ast.c | 12 +-- src/eval/cmd.c | 21 +++-- src/eval/eval.c | 82 ------------------- src/eval/op.c | 49 ++++++++++++ src/eval/redir.c | 13 ++- src/main.c | 236 +++++++++++++++++++++++-------------------------------- 6 files changed, 170 insertions(+), 243 deletions(-) delete mode 100644 src/eval/eval.c create mode 100644 src/eval/op.c (limited to 'src') diff --git a/src/ast.c b/src/ast.c index 1a5f7eb..5b4c3c6 100644 --- a/src/ast.c +++ b/src/ast.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:42 by charles #+# #+# */ -/* Updated: 2020/06/15 13:01:20 by charles ### ########.fr */ +/* Updated: 2020/06/17 16:00:58 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,8 +31,8 @@ t_ast *ast_new(enum e_ast_tag tag) return (NULL); ast->tag = tag; ast->redirs = NULL; - ast->line.left = NULL; - ast->line.right = NULL; + ast->op.left = NULL; + ast->op.right = NULL; ast->cmd_argv = NULL; return (ast); } @@ -52,10 +52,10 @@ void ast_destroy(t_ast *ast) ft_lstdestroy(&ast->cmd_argv, (void (*)(void*))token_destroy); ft_lstdestroy(&ast->redirs, (void (*)(void*))token_destroy); } - else if (ast->tag == AST_LINE) + else if (ast->tag == AST_OP) { - ast_destroy(ast->line.left); - ast_destroy(ast->line.right); + ast_destroy(ast->op.left); + ast_destroy(ast->op.right); } free(ast); } diff --git a/src/eval/cmd.c b/src/eval/cmd.c index 9468cb2..f502984 100644 --- a/src/eval/cmd.c +++ b/src/eval/cmd.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/14 10:41:31 by charles #+# #+# */ -/* Updated: 2020/06/15 11:09:38 by charles ### ########.fr */ +/* Updated: 2020/06/17 17:02:07 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,8 +21,7 @@ */ int fork_wrap( - int fd_in, - int fd_out, + int fds[2], void *passed, int (*wrapped)(void *param)) { @@ -33,14 +32,16 @@ int fork_wrap( return (-1); if (child_pid == 0) { - if ((fd_in != MS_NO_FD && dup2(fd_in, STDIN_FILENO) == -1) || - (fd_out != MS_NO_FD && dup2(fd_out, STDOUT_FILENO) == -1)) + if ((fds[FDS_READ] != MS_NO_FD && dup2(fds[FDS_READ], STDIN_FILENO) == -1) || + (fds[FDS_WRITE] != MS_NO_FD && dup2(fds[FDS_WRITE], STDOUT_FILENO) == -1)) exit(EXIT_FAILURE); if ((status = wrapped(passed)) == -1) exit(EXIT_FAILURE); exit(status); } wait(&child_pid); + close(fds[FDS_WRITE]); + // also read end? return (WEXITSTATUS(child_pid)); } @@ -56,16 +57,12 @@ int forked_cmd(void *void_param) return (execve(param->exec_path, param->argv, (char**)param->env->data)); } -int eval_cmd(t_env env, t_path path, t_ast *ast) +int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast) { t_fork_param_cmd param; - int fd_in; - int fd_out; char **argv; - fd_in = MS_NO_FD; - fd_out = MS_NO_FD; - if (!redir_extract(ast->redirs, env, &fd_in, &fd_out)) + if (!redir_extract(ast->redirs, env, fds)) { ast->redirs = NULL; return (-1); @@ -92,7 +89,7 @@ int eval_cmd(t_env env, t_path path, t_ast *ast) param.argv = argv; param.env = env; - int ret = fork_wrap(fd_in, fd_out, ¶m, &forked_cmd); + int ret = fork_wrap(fds, ¶m, &forked_cmd); ft_split_destroy(argv); return (ret); } diff --git a/src/eval/eval.c b/src/eval/eval.c deleted file mode 100644 index c1b580f..0000000 --- a/src/eval/eval.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* eval.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/04/01 17:05:21 by charles #+# #+# */ -/* Updated: 2020/06/14 10:42:37 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -/* -** \file eval.c -** \brief Evaluation of an AST -*/ - -/* #include "eval.h" */ - -/* #<{(| */ -/* ** \brief Evaluate a line */ -/* ** \param state State of the evaluation */ -/* ** \param line Line to evaluate */ -/* ** \return Last Executed command status or -1 on error */ -/* |)}># */ -/* */ -/* static int eval_line(void *param) */ -/* { */ -/* int status; */ -/* t_eval_state *state; */ -/* t_line *line; */ -/* int fd_in; */ -/* int fd_out; */ -/* */ -/* state = ((t_fork_param_line*)param)->state; */ -/* line = ((t_fork_param_line*)param)->line; */ -/* fd_in = ((t_fork_param_line*)param)->fd_in; */ -/* fd_out = ((t_fork_param_line*)param)->fd_out; */ -/* */ -/* #<{(| if (line->right == NULL) |)}># */ -/* #<{(| return (eval(state, line->left)); |)}># */ -/* */ -/* #<{(| if (line->sep == SEP_PIPE) |)}># */ -/* #<{(| pipe(state->p); |)}># */ -/* */ -/* if (line->left->tag == AST_LINE) */ -/* { */ -/* return (fork_wrap(fd_in, fd_out, param, &eval_line)); */ -/* } */ -/* if ((status = eval(fd_in, fd_out, state, line->left)) == -1) */ -/* return (-1); */ -/* if ((line->sep == SEP_AND && status != 0) || */ -/* (line->sep == SEP_OR && status == 0)) */ -/* return (status); */ -/* */ -/* return (eval(fd_in, fd_out, state, line->right)); */ -/* } */ -/* */ -/* #<{(| */ -/* ** \brief Evaluate an AST */ -/* ** \param state State of the evaluation */ -/* ** \param ast Abstract syntax tree to evaluate */ -/* ** \return Last command status or -1 on error */ -/* |)}># */ -/* */ -/* int eval(int fd_in, int fd_out, t_eval_state *state, t_ast *ast) */ -/* { */ -/* t_fork_param_line param; */ -/* */ -/* errno = 0; */ -/* if (ast->tag == TAG_LINE) */ -/* { */ -/* param.state = state; */ -/* param.line = &ast->line; */ -/* param.fd_in = fd_in; */ -/* param.fd_out = fd_out; */ -/* return (eval_line(¶m)); */ -/* } */ -/* if (ast->tag == TAG_CMD) */ -/* return (eval_cmd(fd_in, fd_out, state, &ast->cmd)); */ -/* return (-1); */ -/* } */ diff --git a/src/eval/op.c b/src/eval/op.c new file mode 100644 index 0000000..e47698b --- /dev/null +++ b/src/eval/op.c @@ -0,0 +1,49 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* op.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/06/17 15:27:22 by charles #+# #+# */ +/* Updated: 2020/06/17 17:03:48 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "eval.h" + +// TODO: add parent tag on first operation of parent to fork +int eval_op(int fds[2], t_env env, t_path path, t_op *op) +{ + int status; + int left_fds[2]; + int right_fds[2]; + int p[2]; + + left_fds[FDS_READ] = fds[FDS_READ]; + left_fds[FDS_WRITE] = MS_NO_FD; + right_fds[FDS_READ] = MS_NO_FD; + right_fds[FDS_WRITE] = fds[FDS_WRITE]; + if (op->sep == TAG_PIPE) + { + pipe(p); + left_fds[FDS_WRITE] = p[FDS_WRITE]; + right_fds[FDS_READ] = p[FDS_READ]; + } + if ((status = eval(left_fds, env, path, op->left)) == -1) + return (-1); + if ((op->sep == TAG_AND && status != 0) || + (op->sep == TAG_PIPE && status != 0) || + (op->sep == TAG_OR && status == 0)) + return (status); + return (eval(right_fds, env, path, op->right)); +} + +int eval(int fds[2], t_env env, t_path path, t_ast *ast) +{ + if (ast->tag == AST_OP) + return (eval_op(fds, env, path, &ast->op)); + if (ast->tag == AST_CMD) + return (eval_cmd(fds, env, path, ast)); + return (-1); +} diff --git a/src/eval/redir.c b/src/eval/redir.c index 5a9d074..7249ad5 100644 --- a/src/eval/redir.c +++ b/src/eval/redir.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/15 11:05:34 by charles #+# #+# */ -/* Updated: 2020/06/15 16:00:40 by charles ### ########.fr */ +/* Updated: 2020/06/17 16:17:43 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,8 +37,7 @@ static bool st_open_replace(int *fd, char *filename, int oflag) bool redir_extract( t_ftlst *redirs, t_env env, - int *fd_in, - int *fd_out) + int fds[2]) { t_ftlst *after; t_ftlst *curr; @@ -66,16 +65,16 @@ bool redir_extract( return (false); } if ((st_lst_tag(redirs) == TAG_REDIR_IN - && !st_open_replace(fd_in, filename, O_RDONLY)) + && !st_open_replace(&fds[FDS_READ], filename, O_RDONLY)) || (st_lst_tag(redirs) == TAG_REDIR_OUT - && !st_open_replace(fd_out, filename, O_WRONLY | O_CREAT | O_TRUNC)) + && !st_open_replace(&fds[FDS_WRITE], filename, O_WRONLY | O_CREAT | O_TRUNC)) || (st_lst_tag(redirs) == TAG_REDIR_APPEND - && !st_open_replace(fd_out, filename, O_WRONLY | O_CREAT | O_APPEND))) + && !st_open_replace(&fds[FDS_WRITE], filename, O_WRONLY | O_CREAT | O_APPEND))) { token_destroy_lst2(redirs, after); return (false); } token_destroy_lst(redirs); free(filename); - return (redir_extract(after, env, fd_in, fd_out)); + return (redir_extract(after, env, fds)); } diff --git a/src/main.c b/src/main.c index 1dee5b1..f6555ad 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 11:45:44 by cacharle #+# #+# */ -/* Updated: 2020/06/16 14:49:59 by charles ### ########.fr */ +/* Updated: 2020/06/17 17:10:08 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,159 +21,123 @@ #include "parser.h" #include "eval.h" -void token_debug(void *v) -{ - t_token *t; - - t= v; - printf("[%4d %d] (%s)\n", t->tag, !!(t->tag & TAG_STICK), t->content); -} +/* void token_debug(void *v) */ +/* { */ +/* t_token *t; */ +/* */ +/* t= v; */ +/* printf("[%4d %d] (%s)\n", t->tag, !!(t->tag & TAG_STICK), t->content); */ +/* } */ +/* */ +/* int main(int argc, char **argv, char **envp) */ +/* { */ +/* t_path path; */ +/* t_env env; */ +/* */ +/* env = env_from_array(envp); */ +/* path = path_update(NULL, env_search(env, "PATH")); */ +/* #<{(| printf("%s\n", argv[2]); |)}># */ +/* */ +/* if (argc == 3 && ft_strcmp(argv[1], "-c") == 0) */ +/* { */ +/* //printf("%s\n", argv[2]); */ +/* t_ftlst *lex_out = lexer(ft_strdup(argv[2])); */ +/* */ +/* //ft_lstiter(lex_out, token_debug); */ +/* */ +/* t_ret *parser_out = parse(lex_out); */ +/* */ +/* #<{(| printf("===cmd_argv===\n"); |)}># */ +/* #<{(| ft_lstiter(parser_out->ast->cmd_argv, token_debug); |)}># */ +/* #<{(| printf("===redirs===\n"); |)}># */ +/* #<{(| ft_lstiter(parser_out->ast->redirs, token_debug); |)}># */ +/* */ +/* int fds[2] = {MS_NO_FD, MS_NO_FD}; */ +/* int eval_out = eval_cmd(fds, env, path, parser_out->ast); */ +/* (void)eval_out; */ +/* } */ +/* */ +/* ft_htdestroy(path, free); */ +/* ft_vecdestroy(env, free); */ +/* return (0); */ +/* } */ int main(int argc, char **argv, char **envp) { + (void)argc; + (void)argv; + /* (void)envp; */ t_path path; t_env env; - + /* char *line; */ + /* int ret; */ env = env_from_array(envp); path = path_update(NULL, env_search(env, "PATH")); - /* printf("%s\n", argv[2]); */ - if (argc == 3 && ft_strcmp(argv[1], "-c") == 0) - { - //printf("%s\n", argv[2]); - t_ftlst *lex_out = lexer(ft_strdup(argv[2])); + t_ftlst *args1 = NULL; + ft_lstpush_back(&args1, ft_lstnew(token_new(TAG_STR, "ls"))); + ft_lstpush_back(&args1, ft_lstnew(token_new(TAG_STR, "-l"))); + + t_ftlst *args2 = NULL; + ft_lstpush_back(&args2, ft_lstnew(token_new(TAG_STR, "cat"))); + ft_lstpush_back(&args2, ft_lstnew(token_new(TAG_STR, "-e"))); + /* ft_lstpush_back(&args2, ft_lstnew(token_new(TAG_STR, "je"))); */ + + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "ls"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "-a"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "-l"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$$LFS$TERM$TERM."))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "*.c"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "src.c include*.h"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$A$B"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "\\$TERM"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$TER\\M"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "\\\\"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_SINGLE, "''''$TEST\\TEST"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE, ",$TEST,$B,"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE , "$TEST"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); */ + /* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_SINGLE, "$TEST"))); */ - //ft_lstiter(lex_out, token_debug); + t_ftlst *redirs = NULL; + ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_OUT, NULL))); + ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "bonjour"))); + /* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_APPEND, NULL))); */ + /* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "yo"))); */ + /* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_OUT, NULL))); */ + /* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "yo1"))); */ - t_ret *parser_out = parse(lex_out); + t_ast *cmd1 = ast_new(AST_CMD); + cmd1->cmd_argv = args1; + cmd1->redirs = NULL; - /* printf("===cmd_argv===\n"); */ - /* ft_lstiter(parser_out->ast->cmd_argv, token_debug); */ - /* printf("===redirs===\n"); */ - /* ft_lstiter(parser_out->ast->redirs, token_debug); */ + t_ast *cmd2 = ast_new(AST_CMD); + cmd2->cmd_argv = args2; + cmd2->redirs = NULL; - int eval_out = eval_cmd(env, path, parser_out->ast); - (void)eval_out; - } + t_ast *op_ast = ast_new(AST_OP); + op_ast->op.left = cmd1; + op_ast->op.right = cmd2; + op_ast->op.sep = TAG_PIPE; + + int fds[2] = {MS_NO_FD, MS_NO_FD}; + printf("eval %d\n", eval(fds, env, path, op_ast)); + + /* char **as = preprocess(l, env); */ + /* printf("%p\n", as); */ + /* printf("%p\n", *as); */ + /* char **tmp = as; */ + /* while (*as != NULL) */ + /* puts(*as++); */ + /* ft_split_destroy(tmp); */ ft_htdestroy(path, free); ft_vecdestroy(env, free); return (0); } -/* int main(int argc, char **argv, char **envp) */ -/* { */ -/* (void)argc; */ -/* (void)argv; */ -/* #<{(| (void)envp; |)}># */ -/* t_path path; */ -/* t_env env; */ -/* #<{(| char *line; |)}># */ -/* #<{(| int ret; |)}># */ -/* env = env_from_array(envp); */ -/* path = path_update(NULL, env_search(env, "PATH")); */ -/* #<{(| |)}># */ -/* #<{(| t_ast *ast; |)}># */ -/* #<{(| t_line line; |)}># */ -/* #<{(| t_cmd cmd; |)}># */ -/* #<{(| t_eval_state state; |)}># */ -/* #<{(| |)}># */ -/* #<{(| cmd.argv = ft_split("ls -l", ' '); |)}># */ -/* #<{(| cmd.in = NULL; |)}># */ -/* #<{(| cmd.out = NULL; |)}># */ -/* #<{(| cmd.is_append = false; |)}># */ -/* #<{(| |)}># */ -/* #<{(| line.left = ast_new(TAG_CMD, &cmd); |)}># */ -/* #<{(| line.right = NULL; |)}># */ -/* #<{(| line.sep = SEP_END; |)}># */ -/* #<{(| ast = ast_new(TAG_LINE, &line); |)}># */ -/* #<{(| printf("%p\n", ast); |)}># */ -/* #<{(| printf("%d\n", ast->tag); |)}># */ -/* #<{(| printf("%p\n", ast->data.line.left); |)}># */ -/* #<{(| printf("%p\n", ast->data.line.right); |)}># */ -/* #<{(| printf("%d\n", ast->data.line.left->tag); |)}># */ -/* #<{(| printf("%p\n", ast->data.line.left->data.cmd.argv); |)}># */ -/* #<{(| printf("%s\n", ast->data.line.left->data.cmd.argv[0]); |)}># */ -/* #<{(| printf("%s\n", ast->data.line.left->data.cmd.argv[1]); |)}># */ -/* #<{(| state.pipe_in[0] = -1; |)}># */ -/* #<{(| state.pipe_in[1] = -1; |)}># */ -/* #<{(| state.pipe_out[0] = -1; |)}># */ -/* #<{(| state.pipe_out[1] = -1; |)}># */ -/* #<{(| state.path = path; |)}># */ -/* #<{(| state.env = env; |)}># */ -/* #<{(| t_io_frame frame; |)}># */ -/* #<{(| io_frame_init(&frame); |)}># */ -/* #<{(| printf("ret: %d %s\n", eval(&frame,&state, ast), strerror(errno)); |)}># */ -/* #<{(| char buf[2048]; |)}># */ -/* #<{(| printf("%s\n", getcwd(buf, 2048)); |)}># */ -/* #<{(| builtin_env(NULL, state.env); |)}># */ -/* #<{(| ast_destroy(ast); |)}># */ -/* #<{(| while ((ret = ft_next_line(STDIN_FILENO, &line)) == 1) |)}># */ -/* #<{(| { |)}># */ -/* #<{(| if (eval(parse(line)) == -1) |)}># */ -/* #<{(| continue ; // and display error |)}># */ -/* #<{(| free(line); |)}># */ -/* #<{(| } |)}># */ -/* #<{(| free(line); |)}># */ -/* #<{(| ms_glob("src#<{(|"); |)}># */ -/* #<{(| char *j = ms_glob("|)}>#*.c"); |)}># */ -/* #<{(| printf("%s\n", j); |)}># */ -/* #<{(| free(j); |)}># */ -/* */ -/* t_ftlst *args = NULL; */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "echo"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "bonjour"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "je"))); |)}># */ -/* */ -/* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "cat"))); */ -/* ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "-e"))); */ -/* */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "ls"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "-a"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "-l"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$$LFS$TERM$TERM."))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "|)}>#*.c"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "src#<{(|.c include#<{(|.h"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$A$B"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "\\$TERM"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "$TER\\M"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR, "\\\\"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_SINGLE, "''''$TEST\\TEST"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE, ",$TEST,$B,"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE , "$TEST"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_DOUBLE | TAG_STICK, "$TEST"))); |)}># */ -/* #<{(| ft_lstpush_back(&args, ft_lstnew(token_new(TAG_STR_SINGLE, "$TEST"))); |)}># */ -/* */ -/* t_ftlst *redirs = NULL; */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_IN, NULL))); */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "bonjour"))); */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_APPEND, NULL))); */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "yo"))); */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_REDIR_OUT, NULL))); */ -/* ft_lstpush_back(&redirs, ft_lstnew(token_new(TAG_STR, "yo1"))); */ -/* */ -/* t_ast *ast = ast_new(AST_CMD); */ -/* ast->cmd_argv = args; */ -/* ast->redirs = redirs; */ -/* */ -/* printf("eval %d\n", eval_cmd(env, path, ast)); */ -/* ast_destroy(ast); */ -/* */ -/* */ -/* #<{(| char **as = preprocess(l, env); |)}># */ -/* #<{(| printf("%p\n", as); |)}># */ -/* #<{(| printf("%p\n", *as); |)}># */ -/* #<{(| char **tmp = as; |)}># */ -/* #<{(| while (*as != NULL) |)}># */ -/* #<{(| puts(*as++); |)}># */ -/* #<{(| ft_split_destroy(tmp); |)}># */ -/* ft_htdestroy(path, free); */ -/* ft_vecdestroy(env, free); */ -/* return (0); */ -/* } */ - ///////////////////////////////////////////////////////////////////////////////////////// // lexer main ///////////////////////////////////////////////////////////////////////////////////////// -- cgit