diff options
| author | nass1pro <nass1pro@gmail.com> | 2020-07-16 10:40:08 +0200 |
|---|---|---|
| committer | nass1pro <nass1pro@gmail.com> | 2020-07-16 10:40:08 +0200 |
| commit | d35382262ea5de1ed6d02b6dd7d269367de4e353 (patch) | |
| tree | c63b0ba102d3d33cde6b24eae856637238ff1248 /src/eval/cmd.c | |
| parent | 8b5147907d20b149ed7c09c0f8a4a4fa49c313bf (diff) | |
| parent | b05db7c497f647c536ec1210be910793c6c7749f (diff) | |
| download | minishell-d35382262ea5de1ed6d02b6dd7d269367de4e353.tar.gz minishell-d35382262ea5de1ed6d02b6dd7d269367de4e353.tar.bz2 minishell-d35382262ea5de1ed6d02b6dd7d269367de4e353.zip | |
Merge branch 'master' of https://github.com/HappyTramp/minishell
Diffstat (limited to 'src/eval/cmd.c')
| -rw-r--r-- | src/eval/cmd.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/eval/cmd.c b/src/eval/cmd.c index 93a5b23..deb7df7 100644 --- a/src/eval/cmd.c +++ b/src/eval/cmd.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/14 10:41:31 by charles #+# #+# */ -/* Updated: 2020/07/15 18:16:27 by charles ### ########.fr */ +/* Updated: 2020/07/16 09:12:02 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,6 +54,7 @@ int forked_cmd(void *void_param) t_fork_param_cmd *param; 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); @@ -78,20 +79,18 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast) ast->redirs = NULL; if ((param.env_local = env_from_array((char*[]){NULL})) == NULL) return (-1); + // TODO generate token list after `=` for variable value preprocessing while (ast->cmd_argv != NULL && ((t_token*)ast->cmd_argv->data)->tag & TAG_IS_STR && utils_start_with_valid_identifier(((t_token*)ast->cmd_argv->data)->content)) { - if (ft_vecpush(param.env_local, ((t_token*)ast->cmd_argv->data)->content) == NULL) + if (env_export_full(param.env_local, ((t_token*)ast->cmd_argv->data)->content) == NULL) return (-1); - ft_lstpop_front(&ast->cmd_argv, NULL); + ft_lstpop_front(&ast->cmd_argv, (void (*)(void*))token_destroy); } - /* printf("[\n"); */ - /* ft_veciter(param.env_local, ft_putendl); */ - /* printf("]\n"); */ if (ast->cmd_argv == NULL) { - /* printf("--\n"); */ + ft_vecpop(param.env_local, NULL); if (ft_vecswallow_at(env, env->size - 1, param.env_local) == NULL) { /* printf("hyo\n"); */ @@ -107,7 +106,6 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast) ast->cmd_argv = NULL; return (-1); } - /* puts(*argv); */ // can have no command (e.g `< file`) if (argv[0] == NULL) |
