/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser_expand.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: sede-san argc) { expanded = parser_expand_word(command->argv[i], minishell, true); if (expanded == NULL) return (false); free(command->argv[i]); command->argv[i] = expanded; i++; } return (true); } static bool expand_redirections( t_list *redirections, t_minishell *minishell, bool expand_vars ) { t_redirection *redirection; char *expanded; while (redirections != NULL) { redirection = (t_redirection *)redirections->content; expanded = parser_expand_word(redirection->target, minishell, expand_vars); if (expanded == NULL) return (false); free(redirection->target); redirection->target = expanded; redirections = redirections->next; } return (true); } void expand( t_list **commands, t_minishell *minishell ) { t_list *current; t_command *command; if (commands == NULL || *commands == NULL) return ; current = *commands; while (current != NULL) { command = (t_command *)current->content; if (!expand_argv(command, minishell) || !expand_redirections(command->redirections, minishell, true) || !expand_redirections(command->heredocs, minishell, false)) { ft_lstclear(commands, (void (*)(void *))command_clear); *commands = NULL; return ; } current = current->next; } }