#98 message d'erreur en cas de fichier corrompu
This commit is contained in:
parent
23da659513
commit
b7e3ef3ecd
1 changed files with 7 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 17:34:23 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 *str;
|
||||||
char *home;
|
char *home;
|
||||||
char *path;
|
char *path;
|
||||||
|
char corrupt;
|
||||||
|
|
||||||
|
corrupt = 0;
|
||||||
if (!(home = ft_getenv(data_singleton()->env, "HOME")))
|
if (!(home = ft_getenv(data_singleton()->env, "HOME")))
|
||||||
return ;
|
return ;
|
||||||
path = ft_str3join(home, "/", ".42sh_history");
|
path = ft_str3join(home, "/", ".42sh_history");
|
||||||
|
|
@ -44,8 +46,12 @@ void ft_init_history(void)
|
||||||
if (ft_str_is_print(str) && *str)
|
if (ft_str_is_print(str) && *str)
|
||||||
ft_push_back_history(&data_singleton()->line.list_beg,
|
ft_push_back_history(&data_singleton()->line.list_beg,
|
||||||
ft_create_history_list(str));
|
ft_create_history_list(str));
|
||||||
|
else
|
||||||
|
corrupt = CORRUPT;
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
if (corrupt)
|
||||||
|
ft_putendl_fd("42sh: corrupt history file /Users/gwojda/.zsh_history", 2);
|
||||||
free(path);
|
free(path);
|
||||||
free(str);
|
free(str);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue