From 82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 30 Oct 2019 20:58:53 +0100 Subject: changes --- src/ft_history.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/ft_history.c') diff --git a/src/ft_history.c b/src/ft_history.c index fa28100..6a82a16 100644 --- a/src/ft_history.c +++ b/src/ft_history.c @@ -1,17 +1,35 @@ +/* ************************************************************************** */ +/* LE - / */ +/* / */ +/* ft_history.c .:: .:/ . .:: */ +/* +:+:+ +: +: +:+:+ */ +/* By: rbousset +:+ +: +: +:+ */ +/* #+# #+ #+ #+# */ +/* Created: 2019/10/30 20:36:05 by rbousset #+# ## ## #+# */ +/* Updated: 2019/10/30 20:36:07 by rbousset ### #+. /#+ ###.fr */ +/* / */ +/* / */ +/* ************************************************************************** */ + #include #include +#include +#include #include #include int -ft_history(const char *arg) +ft_history(char *arg) { + char c; int fd; - int ret; + int r; - if ((fd = open("joe-sh_history", O_RDWR | O_CREAT)) == -1) + if ((fd = open("joe-sh_history", O_CREAT | O_RDWR, 0644)) == -1) return (1); - ret = write(1, arg + "\n", ft_strlen(arg) + 1); + while ((r = read(fd, &c, 1)) != EOF) + puts(&c); + ft_putendl_fd(arg, fd); close(fd); - return (ret); + return (0); } -- cgit v1.2.3