You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

3 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */
3 years ago
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */
3 years ago
/* Updated: 2022/05/06 11:23:19 by narnaud ### ########.fr */
3 years ago
/* */
/* ************************************************************************** */
# include "minishell.h"
int main(int argc, char **argv, char **envp)
3 years ago
{
t_command *cmd;
t_datas datas;
char *line;
int i;
i = 0;
datas.envp = ft_calloc(ENVP_LIMIT, sizeof(char *));
while (*envp)
datas.envp[i++] = ft_strdup(*(envp++));
datas.exit_code = 0;
3 years ago
if (argc < 2)
(void)argv;
while (1)
{
termios(0);
line = readline("$ ");
termios(1);
if (line == NULL)
halt(EXIT_FAILURE);
if (is_empty(line))
continue ;
cmd = parser(&datas, lexer(&datas, line), NULL);
if (!cmd->prev && !cmd->next && is_builtin(cmd->argv[0]))
builtin_call(&datas, cmd);
else
piper(&datas, cmd);
add_history(line);
}
3 years ago
clear_history();
return (EXIT_SUCCESS);
}