some rectif

This commit is contained in:
wescande 2017-03-24 23:06:39 +01:00
parent b75842616b
commit 20cd770d94
2 changed files with 9 additions and 9 deletions

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */ /* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
/* Updated: 2017/03/24 15:11:48 by jhalford ### ########.fr */ /* Updated: 2017/03/24 19:33:00 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -41,25 +41,25 @@ int builtin_export(
char *equal; char *equal;
t_btexport data; t_btexport data;
(void)envp;
(void)path; (void)path;
data.flag = 0; data.flag = 0;
if (cliopts_get((char**)av, g_export_opts, &data)) if (cliopts_get((char**)av, g_export_opts, &data))
ft_perror("export"); return (ft_perror("export") ? 1 : 1);
if (data.flag & BT_EXPORT_LP) if (data.flag & BT_EXPORT_LP)
return (bt_export_print()); return (bt_export_print());
av = data.av_data; av = data.av_data;
if (!(data.flag = 0) && !*av)
bt_export_print();
while (*av) while (*av)
{ {
equal = ft_strchr(*av, '='); equal = ft_strchr(*av, '=');
if (equal) if (equal)
*equal = 0; *(equal++) = 0;
else else
equal = ft_getenv(data_singleton()->local_var, *av); equal = ft_getenv(data_singleton()->local_var, *av);
equal ? equal++ : equal; data.flag += builtin_setenv("internal", (char*[]){"export", *av, equal}, envp);
builtin_setenv("internal", (char*[]){"export", *av, equal}, NULL);
builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL); builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL);
av++; av++;
} }
return (0); return (data.flag ? 1 : 0);
} }

View file

@ -6,13 +6,13 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/23 18:26:59 by jhalford ### ########.fr */ /* Updated: 2017/03/24 19:33:37 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define SETERR_0 "%s: %s: invalid variable name" #define SETERR_0 "%s: not an identifier: %s"
static int assign_var(char *const av[], char ***env) static int assign_var(char *const av[], char ***env)
{ {