From b337b8619041e3b7608d79e35a6be7a77e35b873 Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 22 Oct 2025 19:35:38 +0200 Subject: [PATCH 01/11] structure: moved core functions (init, run, clear) to core.h to prevent circular include --- include/core.h | 52 +++++++++++++++++++++++++++++++++++++++++++++ include/minishell.h | 23 ++------------------ 2 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 include/core.h diff --git a/include/core.h b/include/core.h new file mode 100644 index 0000000..72dad98 --- /dev/null +++ b/include/core.h @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* core.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sede-san // readline(3), rl_clear_history(), // rl_on_new_line(), rl_replace_line(), // rl_redisplay() @@ -36,24 +37,4 @@ # include // tgetent(3), tgetflag(3), tgetnum(3), // tgetstr(3), tgoto(3), tputs(3) -/******************************************************************************/ -/* Structures & Data Types */ -/******************************************************************************/ - -typedef struct s_minishell t_minishell; - -typedef struct s_minishell -{ - char **env; - u_int8_t exit_status; -} t_minishell; - -/* core/minishell.c */ - -extern int minishell_init(struct s_minishell *minishell, char **envp); - -extern u_int8_t minishell_run(struct s_minishell *minishell); - -extern void minishell_clear(struct s_minishell *minishell); - #endif /* MINISHELL_H */ From 6eea2ea17733e84e4fc2a78efc71f9d00faf3568 Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 22 Oct 2025 18:44:05 +0200 Subject: [PATCH 02/11] fix: makefile workflow was not downloading readline library --- .github/workflows/makefile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index eddbbf2..cca06e1 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Prerequisites - run: sudo apt install build-essential + run: sudo apt install build-essential libreadline-dev - name: Show Make Version run: make --version From 6a9d0027a70ea85a24a677f53cc92bcec4a91e22 Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 22 Oct 2025 18:47:06 +0200 Subject: [PATCH 03/11] chore: sync workflow is now done only in main branch --- .github/workflows/sync.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 852da54..1fdb61c 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -2,6 +2,7 @@ name: Update 42 repo on: push: + branches: main permissions: contents: write From 4546c7c252ffd038c0b18b0f131969295927aea3 Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Oct 2025 14:10:48 +0200 Subject: [PATCH 04/11] update: added extremely basic parsing, only for separated environment variables --- include/chardefs.h | 20 +++++++++++ include/minishell.h | 4 ++- include/parser.h | 38 ++++++++++++++++++++ src/parser/parser.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 include/chardefs.h create mode 100644 include/parser.h create mode 100644 src/parser/parser.c diff --git a/include/chardefs.h b/include/chardefs.h new file mode 100644 index 0000000..f56477c --- /dev/null +++ b/include/chardefs.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* chardefs.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sede-san // readline(3), rl_clear_history(), // rl_on_new_line(), rl_replace_line(), // rl_redisplay() diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..61fd6c7 --- /dev/null +++ b/include/parser.h @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parser.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sede-san Date: Thu, 23 Oct 2025 12:43:48 +0200 Subject: [PATCH 05/11] chore: added vgcore files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ae10110..38bd8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ minishell *.su *.idb *.pdb +vgcore* # Kernel Module Compile Results *.mod* From f8c6aed23d3d998b9b2f6201d981747c26d2087e Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Oct 2025 14:15:57 +0200 Subject: [PATCH 06/11] update: variables are now stored separeatedly in t_variables and lines are stored and parsed on each execution --- include/core.h | 28 +++++++++++++++++++++------- src/minishell.c | 14 +++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/include/core.h b/include/core.h index 72dad98..8225dde 100644 --- a/include/core.h +++ b/include/core.h @@ -6,7 +6,7 @@ /* By: sede-san env = envp; + minishell->variables.environment = envp; return (1); } @@ -29,9 +29,16 @@ u_int8_t minishell_run( while (1) { line = readline("minishell > "); + if (!*line) + { + free(line); + continue ; + } + add_history(line); + parse(line, minishell); if (!ft_strcmp(line, "exit")) break ; - printf("%s\n", line); + // printf("%s\n", line); free(line); } free(line); @@ -41,5 +48,6 @@ u_int8_t minishell_run( void minishell_clear( t_minishell *minishell ){ + rl_clear_history(); ft_bzero(minishell, sizeof(t_minishell)); } From 9be000792db4bf597de4f65ac63a424cd15f187c Mon Sep 17 00:00:00 2001 From: Paula Adan Perez Date: Thu, 23 Oct 2025 17:10:25 +0200 Subject: [PATCH 07/11] hola sedesan --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 175ac78..f5c19a3 100644 --- a/src/main.c +++ b/src/main.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: sede-san +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/20 16:34:42 by sede-san #+# #+# */ -/* Updated: 2025/10/22 16:58:08 by sede-san ### ########.fr */ +/* Updated: 2025/10/23 17:10:17 by padan-pe ### ########.fr */ /* */ /* ************************************************************************** */ From 9941529bcf9368572e52e7d401e2b7bd1336d8b0 Mon Sep 17 00:00:00 2001 From: paulillatxulilla Date: Thu, 23 Oct 2025 17:28:15 +0200 Subject: [PATCH 08/11] fgnhhkl From f12a3d896554399777df2dd886d46c9f7dc68f5d Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Oct 2025 22:58:26 +0200 Subject: [PATCH 09/11] chore: suppresed variables that caused errors and removed misplaced function --- src/parser/parser.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/parser/parser.c b/src/parser/parser.c index 5fb39e8..38a2b4c 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -6,13 +6,12 @@ /* By: sede-san Date: Thu, 23 Oct 2025 23:02:44 +0200 Subject: [PATCH 10/11] update: makefile and norminette workflows are now applied only in main and develop branches --- .github/workflows/makefile.yml | 1 + .github/workflows/norminette.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index cca06e1..3e4ae11 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -2,6 +2,7 @@ name: Makefile on: push: + branches: main, develop jobs: check-makefile: diff --git a/.github/workflows/norminette.yml b/.github/workflows/norminette.yml index 843604c..f1352fc 100644 --- a/.github/workflows/norminette.yml +++ b/.github/workflows/norminette.yml @@ -2,6 +2,7 @@ name: Norminette on: push: + branches: main, develop jobs: check-norminette: From 0545809fb6ede675e5ee235107752aad5c154a98 Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 23 Oct 2025 23:08:07 +0200 Subject: [PATCH 11/11] fix: fixed syntax for actions in branches --- .github/workflows/makefile.yml | 4 +++- .github/workflows/norminette.yml | 4 +++- .github/workflows/sync.yml | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 3e4ae11..87bb79e 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -2,7 +2,9 @@ name: Makefile on: push: - branches: main, develop + branches: + - main + - develop jobs: check-makefile: diff --git a/.github/workflows/norminette.yml b/.github/workflows/norminette.yml index f1352fc..174d71f 100644 --- a/.github/workflows/norminette.yml +++ b/.github/workflows/norminette.yml @@ -2,7 +2,9 @@ name: Norminette on: push: - branches: main, develop + branches: + - main + - develop jobs: check-norminette: diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 1fdb61c..68c0a6b 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -2,7 +2,8 @@ name: Update 42 repo on: push: - branches: main + branches: + - main permissions: contents: write