From a7b78272aba413904e570281badf09d26c24034f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Thu, 27 Mar 2025 16:43:21 +0100 Subject: [PATCH] minishell: initialize app struct with env --- src/minishell.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/minishell.c b/src/minishell.c index ecff111..26613b0 100644 --- a/src/minishell.c +++ b/src/minishell.c @@ -6,19 +6,22 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */ -/* Updated: 2025/03/27 15:58:27 by khais ### ########.fr */ +/* Updated: 2025/03/27 16:48:23 by khais ### ########.fr */ /* */ /* ************************************************************************** */ +#include "minishell.h" #include "buffer/buffer.h" +#include "env/env.h" #include "get_command.h" -#include "parser/cmdgroup/cmdgroup.h" #include "parser/simple_cmd/simple_cmd.h" #include "parser/wordlist/wordlist.h" #include "parser/wordsplit/wordsplit.h" #include "postprocess/redirections/redirection_parsing.h" #include "parser/remove_quotes/remove_quotes.h" +#include "libft.h" #include +#include "env/env_convert.h" /* ** Parse shell commands from line. @@ -27,7 +30,7 @@ */ static t_simple_cmd *parse_command(char *line) { - t_wordlist *words; + t_wordlist *words; t_simple_cmd *cmd; words = minishell_wordsplit(line); @@ -67,14 +70,24 @@ static t_simple_cmd *post_process_command(t_simple_cmd *cmd) return (cmd); } +/* +** Initialize main app structure +*/ +static void app_init(t_minishell *app, char **envp) +{ + ft_bzero(app, sizeof(t_minishell)); + app->env = env_from_envp(envp); +} + int main(int argc, char *argv[], char **envp) { char *line; t_simple_cmd *cmd; + t_minishell app; (void)argc; (void)argv; - (void)envp; + app_init(&app, envp); line = get_command(); while (line != NULL) { @@ -83,5 +96,6 @@ int main(int argc, char *argv[], char **envp) debug_command(cmd); line = get_command(); } + env_destroy(app.env); return (0); }