From ff258032adf915aa694feb9654e0a5e6019b3aba Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Fri, 1 Nov 2019 17:45:06 +0100 Subject: Now deals with history --- src/ft_process_arg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ft_process_arg.c') diff --git a/src/ft_process_arg.c b/src/ft_process_arg.c index 75999b9..6a2d155 100644 --- a/src/ft_process_arg.c +++ b/src/ft_process_arg.c @@ -1,15 +1,19 @@ #include +#include #include #include int -ft_process_arg(const char *arg) +ft_process_arg(char *arg) { char **com; + char *prev; uint8_t i; if (arg[0] == '\0') return (0); + if (ft_strncmp(arg, "r", 1)) + ft_history(arg); i = 0; com = ft_split(arg, ' '); while (com[i]) @@ -20,6 +24,14 @@ ft_process_arg(const char *arg) return (ft_echo(com, i)); else if (!ft_strncmp(com[0], "pwd", ft_strlen(com[0]))) return (ft_pwd()); + else if (!ft_strncmp(com[0], "r", 1)) + { + prev = ft_get_last_line(); + ft_putendl(prev); + ft_history("r"); + ft_process_arg(prev); + free(prev); + } else if (!ft_strncmp(com[0], "./", 2)) ft_exec(com); else -- cgit v1.2.3