diff options
| author | Christopher Uhlig | 2025-01-22 02:40:27 +0100 |
|---|---|---|
| committer | Christopher Uhlig | 2025-01-22 02:40:27 +0100 |
| commit | f6e474d27a1398c6d4f2e88c7f2d3797b85217da (patch) | |
| tree | 7dd7bd5f2a151b39498991b567ae51cff8242782 /src/parse_cmd.c | |
| parent | 78dc50a2bce3c6e31405437189e2990d8fc720ac (diff) | |
| download | minishell-f6e474d27a1398c6d4f2e88c7f2d3797b85217da.tar.gz minishell-f6e474d27a1398c6d4f2e88c7f2d3797b85217da.zip | |
kinda fix for pipe error and again.vs for you db just chnage workfolder gn
Diffstat (limited to 'src/parse_cmd.c')
| -rw-r--r-- | src/parse_cmd.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/parse_cmd.c b/src/parse_cmd.c index 3c4eb96..c0a9ad9 100644 --- a/src/parse_cmd.c +++ b/src/parse_cmd.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/08 15:06:25 by dkaiser #+# #+# */ -/* Updated: 2025/01/11 16:04:50 by chuhlig ### ########.fr */ +/* Updated: 2025/01/21 21:27:29 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,10 @@ t_node *parse_cmd(t_token *tokens, t_env **env) { char **args; t_redirection *redirs; + t_list *create_files; - redirs = collect_redirs(&tokens); + create_files = NULL; + redirs = collect_redirs(&tokens, *env, &create_files); if (redirs == NULL) return (NULL); args = collect_args(&tokens, env); @@ -28,7 +30,7 @@ t_node *parse_cmd(t_token *tokens, t_env **env) free(redirs); return (NULL); } - return (new_cmd_node(args, redirs)); + return (new_cmd_node(args, redirs, create_files)); } static char **collect_args(t_token **tokens, t_env **env) @@ -36,6 +38,7 @@ static char **collect_args(t_token **tokens, t_env **env) t_token *cur; char **result; int i; + t_token *next; cur = *tokens; i = 0; @@ -48,11 +51,14 @@ static char **collect_args(t_token **tokens, t_env **env) i = 0; while (cur != NULL && cur->type == STRING_TOKEN) { + next = cur->next; if (cur->previous) free_token(cur->previous); - result[i] = format_string(cur->content.string, *env); + result[i] = format_string(cur->content.string, *env, ft_atoi("0")); i++; - cur = cur->next; + if (cur->next == NULL) + free_token(cur); + cur = next; } result[i] = NULL; return (result); |
