mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
minishell: initialize app struct with env
This commit is contained in:
parent
db1834a620
commit
a7b78272ab
1 changed files with 18 additions and 4 deletions
|
|
@ -6,19 +6,22 @@
|
||||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/06 13:44:06 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 "buffer/buffer.h"
|
||||||
|
#include "env/env.h"
|
||||||
#include "get_command.h"
|
#include "get_command.h"
|
||||||
#include "parser/cmdgroup/cmdgroup.h"
|
|
||||||
#include "parser/simple_cmd/simple_cmd.h"
|
#include "parser/simple_cmd/simple_cmd.h"
|
||||||
#include "parser/wordlist/wordlist.h"
|
#include "parser/wordlist/wordlist.h"
|
||||||
#include "parser/wordsplit/wordsplit.h"
|
#include "parser/wordsplit/wordsplit.h"
|
||||||
#include "postprocess/redirections/redirection_parsing.h"
|
#include "postprocess/redirections/redirection_parsing.h"
|
||||||
#include "parser/remove_quotes/remove_quotes.h"
|
#include "parser/remove_quotes/remove_quotes.h"
|
||||||
|
#include "libft.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "env/env_convert.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Parse shell commands from line.
|
** Parse shell commands from line.
|
||||||
|
|
@ -27,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
static t_simple_cmd *parse_command(char *line)
|
static t_simple_cmd *parse_command(char *line)
|
||||||
{
|
{
|
||||||
t_wordlist *words;
|
t_wordlist *words;
|
||||||
t_simple_cmd *cmd;
|
t_simple_cmd *cmd;
|
||||||
|
|
||||||
words = minishell_wordsplit(line);
|
words = minishell_wordsplit(line);
|
||||||
|
|
@ -67,14 +70,24 @@ static t_simple_cmd *post_process_command(t_simple_cmd *cmd)
|
||||||
return (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)
|
int main(int argc, char *argv[], char **envp)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
t_simple_cmd *cmd;
|
t_simple_cmd *cmd;
|
||||||
|
t_minishell app;
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
(void)envp;
|
app_init(&app, envp);
|
||||||
line = get_command();
|
line = get_command();
|
||||||
while (line != NULL)
|
while (line != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -83,5 +96,6 @@ int main(int argc, char *argv[], char **envp)
|
||||||
debug_command(cmd);
|
debug_command(cmd);
|
||||||
line = get_command();
|
line = get_command();
|
||||||
}
|
}
|
||||||
|
env_destroy(app.env);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue