From 76584b9ff79ae9eaf0c78ca63c03c1c923de1815 Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 17 Mar 2017 13:52:38 +0100 Subject: [PATCH] #113 --- 42sh/src/line-editing/init_history.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/42sh/src/line-editing/init_history.c b/42sh/src/line-editing/init_history.c index 18ba9c85..c6a9b24e 100644 --- a/42sh/src/line-editing/init_history.c +++ b/42sh/src/line-editing/init_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */ -/* Updated: 2017/03/16 11:32:29 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 13:52:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,11 @@ void ft_init_history(void) if (!(home = ft_getenv(data_singleton()->env, "HOME"))) return ; path = ft_str3join(home, "/", ".42sh_history"); - fd = open(path, O_RDONLY); + if ((fd = open(path, O_RDONLY)) < 0) + { + free(path); + return ; + } while (get_next_line(fd, &str) > 0) { if (ft_str_is_print(str) && *str)