From 62baf0e766cf54725ee7c2dc545c56c201022387 Mon Sep 17 00:00:00 2001 From: ntoshihi Date: Wed, 13 Apr 2022 22:54:50 +0900 Subject: [PATCH] made history part --- .gitignore | 4 +++- history.c | 22 ++++++++++++++++++++++ include/minishell.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 history.c diff --git a/.gitignore b/.gitignore index ddc98a8..430d710 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store -main \ No newline at end of file +main +a.out +*.dSYM \ No newline at end of file diff --git a/history.c b/history.c new file mode 100644 index 0000000..f0d20aa --- /dev/null +++ b/history.c @@ -0,0 +1,22 @@ +#include "include/minishell.h" +//gcc history.c -lreadlineでコンパイル +int main() +{ + char *command; + + command = NULL; + while (1) + { + command = readline("6shell> "); + if (command == NULL || strlen(command) == 0) + { + free(command); + break; + } + //printf("command is '%s'\n", command); + add_history(command); + //コマンドの処理 + free(command); + } + return 0; +} \ No newline at end of file diff --git a/include/minishell.h b/include/minishell.h index 4f4e36e..0dca7d5 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -4,3 +4,5 @@ #include #include "./builtin.h" #include +#include +#include