Compare commits

..

2 Commits

Author SHA1 Message Date
Etienne Rey-bethbeder
ec752adbfa Merge branch 'master' of https://git.chauvet.pro/starnakin/minishell 2023-03-13 13:09:48 +01:00
Etienne Rey-bethbeder
dbb39712ea File Descriptor 2 pour les erreurs de export 2023-03-13 13:09:41 +01:00

View File

@ -6,17 +6,17 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
/* Updated: 2023/03/09 19:58:25 by erey-bet ### ########.fr */
/* Updated: 2023/03/13 13:09:13 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./builtins_private.h"
static int error(char *str, int fd)
static int error(char *str)
{
write(fd, "bash: export: `", 15);
write(fd, str, ft_strlen(str));
write(fd, "': not a valid identifier\n", 26);
write(2, "bash: export: `", 15);
write(2, str, ft_strlen(str));
write(2, "': not a valid identifier\n", 26);
return (1);
}
@ -71,7 +71,7 @@ int add_export(t_list **env, char *args, int fd)
if (ft_strchr(args, '=') != NULL)
{
if (set_key_value_export(env, args, &key, &value))
return (error(args, fd));
return (error(args));
}
else
{
@ -80,10 +80,10 @@ int add_export(t_list **env, char *args, int fd)
if (value != NULL)
value = ft_strdup(value);
if (possible_key(key) == 2)
return (error(key, fd));
return (error(key));
}
if (!possible_key(key))
return (error(args, fd));
return (error(args));
create_value_by_key(key, value, env);
return (0);
}