This commit is contained in:
Jack Halford 2017-03-13 18:02:58 +01:00
parent 13ad0dfd34
commit 5b4a1c9a94
3 changed files with 18 additions and 7 deletions

@ -1 +1 @@
Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6
Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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])
{