diff --git a/src/builtin2.c b/src/builtin2.c index 5afdddd..824a0ea 100644 --- a/src/builtin2.c +++ b/src/builtin2.c @@ -6,7 +6,7 @@ /* By: jschaft +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/25 13:28:29 by jschaft #+# #+# */ -/* Updated: 2024/06/28 14:26:05 by mcolonna ### ########.fr */ +/* Updated: 2024/06/28 14:50:17 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,11 +15,29 @@ // TODO 'name=value' notation int export_builtin(t_env *env, t_call call) { - int i; + int i; + char *name; + char *value; + char **splitted; + const t_memclass mc = mem_subclass(fatal_error, env->mc_global); i = 0; while (call.argv[++i]) - variables_export(env->variables, call.argv[i]); + { + if (char_isin('=', call.argv[i])) + { + splitted = str_split(fatal_error, mc, call.argv[i], "="); + name = splitted[0]; + value = splitted[1]; + if (!value) + value = ""; + variables_set(env->variables, name, value); + } + else + name = call.argv[i]; + variables_export(env->variables, name); + } + mem_freeall(mc); return (0); }