minishell: initialize app struct with env

This commit is contained in:
Khaïs COLIN 2025-03-27 16:43:21 +01:00
parent db1834a620
commit a7b78272ab
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -6,19 +6,22 @@
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <stdlib.h>
#include "env/env_convert.h"
/*
** Parse shell commands from 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);
}