/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* minishell.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ /* Updated: 2022/05/06 11:23:19 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ # include "minishell.h" int main(int argc, char **argv, char **envp) { 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; 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); } clear_history(); return (EXIT_SUCCESS); }