aboutsummaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-11 19:18:17 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-11 19:18:17 +0200
commit9446bb78646bef4e3449a59a9e01118b025402bf (patch)
treea078d7f9244c90ffcc00e493cacee5595c054dbb /src/eval
parent98990d5195e93154abbfd16eaa9d1fcc3572bc5c (diff)
downloadminishell-9446bb78646bef4e3449a59a9e01118b025402bf.tar.gz
minishell-9446bb78646bef4e3449a59a9e01118b025402bf.tar.bz2
minishell-9446bb78646bef4e3449a59a9e01118b025402bf.zip
Removing command local variable
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/cmd.c35
-rw-r--r--src/eval/variable.c42
2 files changed, 7 insertions, 70 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, &param, &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));
-}