File Descriptor 2 pour les erreurs de export

This commit is contained in:
Etienne Rey-bethbeder 2023-03-13 13:09:41 +01:00
parent 0694b36a72
commit dbb39712ea

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);
}