From 5680ec97a94d4e955e26a4dc6548d675d8211398 Mon Sep 17 00:00:00 2001 From: narnaud Date: Wed, 18 May 2022 15:25:21 +0200 Subject: [PATCH] fix unamed variable export --- env.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/env.c b/env.c index 537bf4c..e3a7294 100755 --- a/env.c +++ b/env.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/16 09:41:29 by narnaud #+# #+# */ -/* Updated: 2022/05/18 13:54:55 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/18 15:24:19 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,16 +70,26 @@ int ft_export(t_datas *datas, t_command *cmd) char **env; int i; int j; + int ret ; + ret = 0; if (cmd->argc < 2 && (ft_env(datas, cmd, 1), 1)) - return (0); + return (ret); j = 0; while (++j < cmd->argc) { + if (!cmd->argv[j][0] || cmd->argv[j][0] == '=') + { + ret = 1; + continue ; + } new = ft_split(cmd->argv[j], '='); name_len = ft_strlen(new[0]); if (!is_valid_identifier(new[0])) - return (0); + { + ret = 1; + continue ; + } i = 0; while (datas->envp[i]) { @@ -93,7 +103,7 @@ int ft_export(t_datas *datas, t_command *cmd) ft_free_split(new); datas->envp[i] = ft_strdup(cmd->argv[j]); } - return (0); + return (ret); } static void clean_env(t_datas *datas, int i)