From 5b4a1c9a946d9d7671812c0e34c0afc377c7f351 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 13 Mar 2017 18:02:58 +0100 Subject: [PATCH] issue #97 --- 42sh/libft | 2 +- 42sh/src/builtin/builtin_export.c | 17 +++++++++++++---- 42sh/src/builtin/builtin_setenv.c | 6 ++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/42sh/libft b/42sh/libft index b209bb1f..9382dc10 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6 +Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71 diff --git a/42sh/src/builtin/builtin_export.c b/42sh/src/builtin/builtin_export.c index 9a1db23c..e20d9f8c 100644 --- a/42sh/src/builtin/builtin_export.c +++ b/42sh/src/builtin/builtin_export.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */ -/* Updated: 2017/03/13 17:48:21 by ariard ### ########.fr */ +/* Updated: 2017/03/13 18:01:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,16 @@ int builtin_export(const char *path, char *const av[], char *const envp[]) { - if (ft_strcmp(av[0], "export") == 0) - av++; - return (builtin_setenv(path, av, envp)); + char *equal; + + if ((equal = ft_strchr(av[1], '='))) + { + *equal = 0; + return (builtin_setenv(path, (char*[]){"setenv", av[1], equal + 1}, envp)); + } + else + { + // export doit chercher cette variable locale et la mettre dans l'env + return (0); + } } diff --git a/42sh/src/builtin/builtin_setenv.c b/42sh/src/builtin/builtin_setenv.c index d5d5f99f..5aae2425 100644 --- a/42sh/src/builtin/builtin_setenv.c +++ b/42sh/src/builtin/builtin_setenv.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ -/* Updated: 2017/03/07 11:28:05 by ariard ### ########.fr */ +/* Updated: 2017/03/13 18:01:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,8 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[]) (void)path; i = 0; env = &data_singleton()->env; - if (ft_strcmp(av[0], "setenv") == 0) + if (ft_strcmp(av[0], "setenv") == 0 + || ft_strcmp(av[0], "export") == 0) av++; if (!av[0]) { @@ -31,6 +32,7 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[]) } else { + DG("str3join(%s,%s,%s)", av[0], "=", av[1]); str = ft_str3join(av[0], "=", av[1]); while ((*env)[i]) {