diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval/cmd.c | 35 | ||||
| -rw-r--r-- | src/eval/variable.c | 42 | ||||
| -rw-r--r-- | src/lexer/tok_lst.c | 20 | ||||
| -rw-r--r-- | src/main.c | 4 |
4 files changed, 10 insertions, 91 deletions
diff --git a/src/eval/cmd.c b/src/eval/cmd.c index 36e5a00..44f22b6 100644 --- a/src/eval/cmd.c +++ b/src/eval/cmd.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/14 10:41:31 by charles #+# #+# */ -/* Updated: 2020/09/10 20:32:13 by charles ### ########.fr */ +/* Updated: 2020/09/11 19:10:20 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,12 +56,12 @@ int forked_cmd(void *void_param) struct stat statbuf; param = void_param; - ft_vecpop(param->env_local, NULL); - if (ft_vecswallow_at(param->env, param->env->size - 1, param->env_local) == NULL) - { - ft_vecdestroy(param->env_local, free); - return (EVAL_FATAL); - } + /* ft_vecpop(param->env_local, NULL); */ + /* if (ft_vecswallow_at(param->env, param->env->size - 1, param->env_local) == NULL) */ + /* { */ + /* ft_vecdestroy(param->env_local, free); */ + /* return (EVAL_FATAL); */ + /* } */ if (param->builtin != NULL) return (param->builtin->func(param->argv, param->env)); else @@ -92,26 +92,6 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast) if ((status = redir_extract(&ast->redirs, env, fds)) != 0) return (status); - if ((param.env_local = env_from_array((char*[]){NULL})) == NULL) - return (EVAL_FATAL); - if (!variable_extract(&ast->cmd_argv, env, param.env_local)) - return (EVAL_FATAL); - - /* char **strs = preprocess(&start, env); */ - /* */ - /* if (env_export(env_local, id, strs[0]) == NULL) */ - /* return (-1); */ - /* if (ast->cmd_argv == NULL) // FIXME special env not passed to child processes */ - /* { */ - /* ft_vecpop(param.env_local, NULL); */ - /* if (ft_vecswallow_at(env, env->size - 1, param.env_local) == NULL) */ - /* { */ - /* ft_vecdestroy(param.env_local, free); */ - /* return (-1); */ - /* } */ - /* g_last_status = 0; */ - /* return (0); */ - /* } */ if ((argv = preprocess(&ast->cmd_argv, env)) == NULL) { @@ -140,7 +120,6 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast) param.env = env; status = fork_wrap(fds, ¶m, &forked_cmd); ft_split_destroy(argv); - ft_vecdestroy(param.env_local, free); g_last_status = status; return (status); } diff --git a/src/eval/variable.c b/src/eval/variable.c deleted file mode 100644 index 2b6d7cf..0000000 --- a/src/eval/variable.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* variable.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/09/09 17:12:14 by charles #+# #+# */ -/* Updated: 2020/09/09 18:22:43 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "eval.h" - -bool variable_extract(t_tok_lst **argv, t_env env, t_env env_local) -{ - char *key; - t_tok_lst *value_tokens; - char **strs; - - if (*argv == NULL || !((*argv)->tag & TAG_STR) - || !utils_start_with_valid_identifier((*argv)->content)) - return (true); - - key = (*argv)->content; - (*argv)->content = ft_strchr(key, '='); - *(*argv)->content = '\0'; - (*argv)->content++; - (*argv)->content = ft_strdup((*argv)->content); - - /* printf("|%s| |%s|\n", key, (*argv)->content); */ - /* if (*(*argv)->content == '\0') */ - /* { */ - /* ft_lstpop_front((t_ftlst**)argv, NULL); */ - /* return (true); */ - /* } */ - value_tokens = tok_lst_take_sticked(argv); - strs = preprocess(&value_tokens, env); - if (env_export(env_local, key, strs[0]) == NULL) - return (false); - return (variable_extract(argv, env, env_local)); -} diff --git a/src/lexer/tok_lst.c b/src/lexer/tok_lst.c index 83f50bf..debeb9a 100644 --- a/src/lexer/tok_lst.c +++ b/src/lexer/tok_lst.c @@ -6,7 +6,7 @@ /* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/08/27 09:32:58 by charles #+# #+# */ -/* Updated: 2020/09/09 18:10:26 by charles ### ########.fr */ +/* Updated: 2020/09/11 19:11:20 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,21 +70,3 @@ t_tok_lst *tok_lst_uncons(t_tok_lst **tokens) poped->next = NULL; return (poped); } - -t_tok_lst *tok_lst_take_sticked(t_tok_lst **tokens) -{ - t_tok_lst *start; - t_tok_lst *curr; - - if (*tokens == NULL) - return (NULL); - start = *tokens; - curr = *tokens; - while (curr->tag & TAG_STICK && curr->tag & TAG_IS_STR) - curr = curr->next; - /* if (curr->tag & TAG_IS_STR) */ - /* curr = curr->next; */ - *tokens = curr->next; - curr->next = NULL; - return (start); -} @@ -6,7 +6,7 @@ /* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 11:45:44 by cacharle #+# #+# */ -/* Updated: 2020/09/10 20:26:19 by charles ### ########.fr */ +/* Updated: 2020/09/11 19:18:00 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,9 +29,9 @@ void tok_lst_debug(t_tok_lst *tokens); /* ** TODO ** $? +** pipe make 2 new children ** concurrent pipeline ** signal on whole line instead of single command -** env local to current minishell process */ bool env_set_default(t_env env, char *key, char *value) |
