summaryrefslogtreecommitdiffstats
path: root/src/ft_history.c
blob: 6a82a16c6992b097f33bae73aad7514c41e8aaf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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(char *arg)
{
	char c;
	int fd;
	int r;

	if ((fd = open("joe-sh_history", O_CREAT | O_RDWR, 0644)) == -1)
		return (1);
	while ((r = read(fd, &c, 1)) != EOF)
		puts(&c);
	ft_putendl_fd(arg, fd);
	close(fd);
	return (0);
}