summaryrefslogtreecommitdiffstats
path: root/src/ft_history.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-10-30 20:58:53 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-10-30 20:58:53 +0100
commit82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8 (patch)
tree50eabf3f9c3975d2a3ff204fd48cdfeab3cef861 /src/ft_history.c
parentwork work (diff)
download42-minishell-82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8.tar.gz
42-minishell-82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8.tar.bz2
42-minishell-82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8.tar.xz
42-minishell-82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8.tar.zst
42-minishell-82b2fa3b5d726c99dbed0c2717f8ab9c415ac5f8.zip
changes
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);
}