From 8becb3f4682623bc4b9f9b2d9e09102672ef1790 Mon Sep 17 00:00:00 2001 From: mdev9 Date: Wed, 24 Apr 2024 10:32:29 +0200 Subject: [PATCH] fixed double here_doc --- srcs/here_doc.c | 8 +++++++- todo_list | 28 +++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/srcs/here_doc.c b/srcs/here_doc.c index ac9bfa1..e23bf25 100755 --- a/srcs/here_doc.c +++ b/srcs/here_doc.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */ -/* Updated: 2024/04/23 17:07:00 by tomoron ### ########.fr */ +/* Updated: 2024/04/24 09:57:20 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -68,6 +68,12 @@ void handle_here_doc(t_msh *msh, char *eof) int pid; here_doc_file = get_tmp_file_name(msh); + if (msh->here_doc_filename) + { + close(msh->in_fd); + unlink(msh->here_doc_filename); + free(msh->here_doc_filename); + } msh->here_doc_filename = here_doc_file; msh->in_fd = open(here_doc_file, O_CREAT | O_RDWR, 0644); if (msh->in_fd == -1) diff --git a/todo_list b/todo_list index 47fb676..ae82754 100644 --- a/todo_list +++ b/todo_list @@ -1,6 +1,28 @@ unset HOME cd | lolcat -double here_doc and manual here_doc tests -$OLDPWD and $PWD (manual tests) +$SHLVL + + +cat