diff --git a/src/minishell.c b/src/minishell.c index 3e87f9e..ecff111 100644 --- a/src/minishell.c +++ b/src/minishell.c @@ -6,13 +6,14 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */ -/* Updated: 2025/03/20 17:36:58 by khais ### ########.fr */ +/* Updated: 2025/03/27 15:58:27 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "buffer/buffer.h" #include "get_command.h" #include "parser/cmdgroup/cmdgroup.h" +#include "parser/simple_cmd/simple_cmd.h" #include "parser/wordlist/wordlist.h" #include "parser/wordsplit/wordsplit.h" #include "postprocess/redirections/redirection_parsing.h" @@ -24,29 +25,30 @@ ** ** Frees line before exiting */ -static t_cmdgroup *parse_command(char *line) +static t_simple_cmd *parse_command(char *line) { t_wordlist *words; - t_cmdgroup *cmd; + t_simple_cmd *cmd; words = minishell_wordsplit(line); free(line); - cmd = cmdgroup_from_wordlist(words); - wordlist_destroy(words); + if (words == NULL) + return (NULL); + cmd = simple_cmd_from_wordlist(words); return (cmd); } /* ** debug-print a cmdgroup */ -static void debug_command(t_cmdgroup *cmd) +static void debug_command(t_simple_cmd *cmd) { t_buffer *indent; indent = ft_buffer_new(); - cmdgroup_debug(cmd, indent, true); + simple_cmd_debug(cmd, indent, true); ft_buffer_free(indent); - cmdgroup_destroy(cmd); + simple_cmd_destroy(cmd); } /* @@ -56,19 +58,19 @@ static void debug_command(t_cmdgroup *cmd) ** 1. redirection parsing ** 2. quote removal */ -static t_cmdgroup *post_process_command(t_cmdgroup *cmd) +static t_simple_cmd *post_process_command(t_simple_cmd *cmd) { - if (cmdgroup_parse_redirections(cmd) == NULL) - return (cmdgroup_destroy(cmd), NULL); - if (cmdgroup_remove_quotes(cmd) == NULL) - return (cmdgroup_destroy(cmd), NULL); + if (parse_redirections(cmd) == NULL) + return (simple_cmd_destroy(cmd), NULL); + if (simple_cmd_remove_quotes(cmd) == NULL) + return (simple_cmd_destroy(cmd), NULL); return (cmd); } int main(int argc, char *argv[], char **envp) { - char *line; - t_cmdgroup *cmd; + char *line; + t_simple_cmd *cmd; (void)argc; (void)argv; diff --git a/src/parser/remove_quotes/cmdgroup_remove_quotes.c b/src/parser/remove_quotes/cmdgroup_remove_quotes.c index 56f3373..3f30baf 100644 --- a/src/parser/remove_quotes/cmdgroup_remove_quotes.c +++ b/src/parser/remove_quotes/cmdgroup_remove_quotes.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/20 17:36:20 by khais #+# #+# */ -/* Updated: 2025/03/21 18:33:43 by khais ### ########.fr */ +/* Updated: 2025/03/27 14:27:14 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ /* ** do quote removal on all words of this simple cmd */ -static t_simple_cmd *simple_cmd_remove_quotes(t_simple_cmd *cmd) +t_simple_cmd *simple_cmd_remove_quotes(t_simple_cmd *cmd) { t_wordlist *new; t_worddesc *result; diff --git a/src/parser/remove_quotes/remove_quotes.h b/src/parser/remove_quotes/remove_quotes.h index dc5f8bc..0557738 100644 --- a/src/parser/remove_quotes/remove_quotes.h +++ b/src/parser/remove_quotes/remove_quotes.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/28 13:51:03 by khais #+# #+# */ -/* Updated: 2025/03/20 17:36:11 by khais ### ########.fr */ +/* Updated: 2025/03/27 14:27:27 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,8 @@ # include "../worddesc/worddesc.h" # include "../cmdgroup/cmdgroup.h" -t_worddesc *remove_quotes(t_worddesc *word); -t_cmdgroup *cmdgroup_remove_quotes(t_cmdgroup *cmd); +t_worddesc *remove_quotes(t_worddesc *word); +t_cmdgroup *cmdgroup_remove_quotes(t_cmdgroup *cmd); +t_simple_cmd *simple_cmd_remove_quotes(t_simple_cmd *cmd); #endif // REMOVE_QUOTES_H diff --git a/test.sh b/test.sh index 352af17..03241b9 100755 --- a/test.sh +++ b/test.sh @@ -116,197 +116,8 @@ when_run <outfile -EOF -expecting < out -EOF -expecting <outfile there < infile < infile2 >> append -EOF -expecting <> append | echo < infile bye && echo hello > outfile) -EOF -expecting <