int ft_isbuiltin(t_env *env, char *line) { char **line2; int i; t_main w; i = 0; line2 = ft_strsplit(line, ' '); if (ft_strcmp(line2[0], "echo") == 0 && (i = 1)) { line = ft_strfcut(line, 5); ft_echo(line); } else if (ft_strncmp(line, "cd", 2) == 0 && (i = 1)) ft_cd(line); else if (ft_strncmp(line, "unsetenv", 7) == 0 && (i = 1)) env = ft_unsetenv(env); else if (ft_strncmp(line, "env", 2) == 0 && (i = 1)) print_env(env); else if (ft_strncmp(line, "setenv", 5) == 0 && (i = 1)) { line = ft_strrw(line); line2 = ft_strsplit(line, ' '); env = set_env(line2, env); } if (i == 1) ft_doublecoms(env, &w, 0); return (1); }
void ft_doublecoms(t_env *env, t_main *w) { char **coms; int i; i = 0; coms = NULL; w->line = NULL; ft_selectinit(w); while (ft_select(w, &w->line)) ; ft_selectend(w); w = ft_keep_main(*w, 0); if (ft_strchr(w->line, '>') != 0 || ft_strchr(w->line, '<') != 0) ft_redirect(w, env); if (ft_strchr(w->line, ';') == 0 && ft_strchr(w->line, '|') == 0) ft_minishell(env, w); else if (ft_strchr(w->line, '|') == 0 && ft_strchr(w->line, ';') != 0) semicolon(w, env, coms); else if (ft_strchr(w->line, '|') != 0) com_pipes(w, env, coms); if (i == 0) ft_doublecoms(env, w); }