42_minishell/builtins/export.c
Etienne Rey-bethbeder 5175073708 SBEUB SBEUB ARABE
2023-02-17 17:46:12 +01:00

32 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* export.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
/* Updated: 2023/02/14 14:52:50 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "../minishell.h"
int print_export(t_list **head, int fd)
{
t_list *current;
current = *head;
while (current->next != NULL)
{
write(fd, "declare -x ", 11);
ft_putstr_fd(((t_env *)(current->content))->key, fd);
ft_putstr_fd("=", fd);
write(fd, "\"", 1);
ft_putstr_fd(((t_env *)(current->content))->value, fd);
write(fd, "\"\n", 2);
current = current->next;
}
return (0);
}