From 4543c3ba3222d47780ad3e091cfe6f3098cc2bca Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 6 Sep 2020 21:56:20 +0200 Subject: Stacked --- src/m_loop.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/m_loop.c') diff --git a/src/m_loop.c b/src/m_loop.c index 17668a5..d5a3ceb 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -15,7 +15,9 @@ #include #include #include +#include +#include "d_define.h" #include "e_line.h" #include "m_loop_next.h" #include "m_prompt.h" @@ -36,18 +38,20 @@ void m_dump_hist(t_msh *msh) { int32_t fd; - char *histfile_path; + char histfile[PATH_MAX]; - if (ft_strlen(msh->hist) > 0 && - (histfile_path = u_get_var_value("$HISTFILE", msh)) != NULL) + if (ft_strlen(msh->hist) > 0) { - if ((fd = open(histfile_path, - O_WRONLY | O_CREAT | O_APPEND, 0644)) != -1) + u_get_var_value(histfile, "$HISTFILE", PATH_MAX, msh); + if (histfile[0] != C_NUL) { - write(fd, msh->hist, ft_strlen(msh->hist)); - close(fd); + if ((fd = open(histfile, + O_WRONLY | O_CREAT | O_APPEND, 0644)) != -1) + { + ft_dprintf(fd, "%s", msh->hist); + close(fd); + } } - ft_memdel((void*)&histfile_path); } } -- cgit v1.2.3