From a42364701e4f6705352d07a64ff5f3c373bf4422 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 1 Aug 2024 15:05:00 +0200 Subject: [PATCH] Let environment be inhereted by child processes By implementing add_exported function. --- src/execution.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/execution.c b/src/execution.c index 72be3b3..c523085 100644 --- a/src/execution.c +++ b/src/execution.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */ -/* Updated: 2024/08/01 14:28:28 by ljiriste ### ########.fr */ +/* Updated: 2024/08/01 15:04:10 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -643,6 +643,8 @@ char *find_exe(const char *exe_name, const t_execution_env *env) char *res; path = get_env_var_value(env, "PATH"); + if (!path) + return (NULL); paths = ft_split(path, ":"); if (!paths) return (NULL); @@ -676,6 +678,19 @@ int dup_redirections(__attribute__((unused)) const t_vec *redirections) int add_exported(__attribute__((unused)) t_vec *assignments, __attribute__((unused)) const t_execution_env *env) { + size_t i; + char *var; + const t_vec *exported; + + exported = &env->vars->exported; + i = 0; + while (i < exported->size) + { + var = ft_strdup(*(char *const *)ft_vec_caccess(exported, i)); + if (ft_vec_append(assignments, &var) != success) // Should exported be overwritten? + return (1); + ++i; + } return (0); } -- 2.30.2