|
|
@ -6,7 +6,7 @@ |
|
|
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
|
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
|
/* 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) |
|
|
|