From b7e3ef3ecda33df19e2b7c44742f7f3f01dd4789 Mon Sep 17 00:00:00 2001 From: gwojda Date: Tue, 14 Mar 2017 13:50:39 +0100 Subject: [PATCH] #98 message d'erreur en cas de fichier corrompu --- 42sh/src/line-editing/init_history.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/42sh/src/line-editing/init_history.c b/42sh/src/line-editing/init_history.c index d74f4e14..44b56f87 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/14 13:42:15 by gwojda ### ########.fr */ +/* Updated: 2017/03/14 13:48:23 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,9 @@ void ft_init_history(void) char *str; char *home; char *path; + char corrupt; + corrupt = 0; if (!(home = ft_getenv(data_singleton()->env, "HOME"))) return ; path = ft_str3join(home, "/", ".42sh_history"); @@ -44,8 +46,12 @@ void ft_init_history(void) if (ft_str_is_print(str) && *str) ft_push_back_history(&data_singleton()->line.list_beg, ft_create_history_list(str)); + else + corrupt = CORRUPT; free(str); } + if (corrupt) + ft_putendl_fd("42sh: corrupt history file /Users/gwojda/.zsh_history", 2); free(path); free(str); close(fd);