From c9b17eb1b25a22ed024aaafc1e669dfbfe1bc5b0 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 30 Oct 2019 20:35:40 +0100 Subject: work work --- inc/minishell.h | 2 ++ src/ft_exec.c | 5 +---- src/ft_history.c | 17 +++++++++++++++++ src/main.c | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/ft_history.c diff --git a/inc/minishell.h b/inc/minishell.h index 3dfc3ae..bbb4c2c 100644 --- a/inc/minishell.h +++ b/inc/minishell.h @@ -3,6 +3,8 @@ #include +#define FT_PS1 "joe-sh~> " + int ft_process_arg(const char *arg); int ft_echo(char **com, uint8_t n); int ft_pwd(void); diff --git a/src/ft_exec.c b/src/ft_exec.c index 7177f5b..31fcaf2 100644 --- a/src/ft_exec.c +++ b/src/ft_exec.c @@ -10,9 +10,6 @@ ft_exec(char **app) i = 0; while (app[i]) i++; - if (i < 2) - return (execve(app[0] + 2, NULL, NULL)); - else - return (execve(app[0] + 2, &app[1], NULL)); + return (execve(app[0] + 2, app, NULL)); return (0); } diff --git a/src/ft_history.c b/src/ft_history.c new file mode 100644 index 0000000..fa28100 --- /dev/null +++ b/src/ft_history.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +int +ft_history(const char *arg) +{ + int fd; + int ret; + + if ((fd = open("joe-sh_history", O_RDWR | O_CREAT)) == -1) + return (1); + ret = write(1, arg + "\n", ft_strlen(arg) + 1); + close(fd); + return (ret); +} diff --git a/src/main.c b/src/main.c index bcdb4c2..1f18c9b 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ int arg = NULL; while (1) { - write(1, "joe-sh~> ", 9); + ft_putstr(FT_PS1); if (arg) { free(arg); -- cgit v1.2.3