summaryrefslogtreecommitdiffstats
path: root/src/ft_process_arg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_process_arg.c')
-rw-r--r--src/ft_process_arg.c14
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