summaryrefslogtreecommitdiffstats
path: root/src/ft_history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_history.c')
-rw-r--r--src/ft_history.c28
1 files changed, 23 insertions, 5 deletions
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 <marvin@le-101.fr> +:+ +: +: +:+ */
+/* #+# #+ #+ #+# */
+/* Created: 2019/10/30 20:36:05 by rbousset #+# ## ## #+# */
+/* Updated: 2019/10/30 20:36:07 by rbousset ### #+. /#+ ###.fr */
+/* / */
+/* / */
+/* ************************************************************************** */
+
#include <libft.h>
#include <minishell.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
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);
}