diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-11-01 17:45:06 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-11-01 17:45:06 +0100 |
commit | ff258032adf915aa694feb9654e0a5e6019b3aba (patch) | |
tree | eb88e61ef0c3729aa4df2d28448f74505c51949f /src/ft_process_arg.c | |
parent | YO PICKED THE WRONG FOOL, HOUSE (diff) | |
download | 42-minishell-ff258032adf915aa694feb9654e0a5e6019b3aba.tar.gz 42-minishell-ff258032adf915aa694feb9654e0a5e6019b3aba.tar.bz2 42-minishell-ff258032adf915aa694feb9654e0a5e6019b3aba.tar.xz 42-minishell-ff258032adf915aa694feb9654e0a5e6019b3aba.tar.zst 42-minishell-ff258032adf915aa694feb9654e0a5e6019b3aba.zip |
Now deals with history
Diffstat (limited to 'src/ft_process_arg.c')
-rw-r--r-- | src/ft_process_arg.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 <libft.h> +#include <stdlib.h> #include <minishell.h> #include <inttypes.h> 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 |