void ft_dless(t_parser *parser, t_data *d) { char **tab; int fd; tab = ft_strsplit_shell(parser->left->str); if (!tab || !tab[0]) { ft_putendl_fd("parser error", 2); return ; } ft_heredoc(tab); ft_tabdel(&tab); fd = open("/tmp/.less", O_RDONLY); dup2(fd, 0); d->redirect = 0; ft_process_tree(parser->right, d); d->redirect = 1; dup2(d->save_fd[0], 0); close(fd); }
void ft_process(t_data *d, char *str) { int i; char **tab; char *tmp; i = 0; tmp = ft_tilde(str, d); tab = ft_strsplit_shell(tmp); ft_strdel(&tmp); if (tab && tab[0]) { ft_search_alias(d, &tab); ft_builtin(d, tab, &i); if (i == 0) { if (ft_exec(ft_convert_ltt(d->my_env), tab, d->fork) == 0) ft_printf("42sh: command not found: %s\n", tab[0]); } } ft_free_tab(&tab); }
void ft_great(t_parser *parser, t_data *d) { int fd; char **tab; char *tmp; tmp = ft_bquote(d, parser->left->str); tab = ft_strsplit_shell(tmp); ft_strdel(&tmp); fd = open(tab[0], O_CREAT | O_TRUNC | O_RDWR, 0644); if (ft_check_error(tab, fd)) { ft_tabdel(&tab); return ; } ft_tabdel(&tab); if (d->pipe == 0) dup2(fd, 1); ft_process_tree(parser->right, d); if (d->pipe == 0) dup2(d->save_fd[1], 1); close(fd); }