aboutsummaryrefslogtreecommitdiff
path: root/src/collect_redirs.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-09-17 19:25:13 +0200
committerDominik Kaiser2024-09-17 19:25:13 +0200
commit1fec66236f1811a3eeac673d0002fe8d9d3d8835 (patch)
tree8e007570a2109a3cb756c2d699ff4f6a20b75317 /src/collect_redirs.c
parente8891daeb2e9cf26dc6be1f4d3693734d7a9c5c1 (diff)
downloadminishell-1fec66236f1811a3eeac673d0002fe8d9d3d8835.tar.gz
minishell-1fec66236f1811a3eeac673d0002fe8d9d3d8835.zip
Fix error message printing
Diffstat (limited to 'src/collect_redirs.c')
-rw-r--r--src/collect_redirs.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/collect_redirs.c b/src/collect_redirs.c
index 79ae95c..60f197b 100644
--- a/src/collect_redirs.c
+++ b/src/collect_redirs.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 13:49:31 by dkaiser #+# #+# */
-/* Updated: 2024/09/17 17:24:35 by dkaiser ### ########.fr */
+/* Updated: 2024/09/17 19:24:55 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,6 +21,7 @@ t_redirection *collect_redirs(t_token **tokens)
{
t_redirection *result;
t_token *cur;
+ int is_redir_only;
cur = *tokens;
result = malloc(sizeof(t_redirection) * 2);
@@ -31,20 +32,21 @@ t_redirection *collect_redirs(t_token **tokens)
while (cur != NULL && cur->next != NULL)
{
if (cur->type == REDIR_TOKEN && cur->next->type == STRING_TOKEN)
+ {
+ is_redir_only = 0;
+ if (cur->previous == NULL && cur->next->next == NULL)
+ is_redir_only = 1;
cur = collect_redir(tokens, result, cur);
+ if (is_redir_only)
+ *tokens = NULL;
+ }
else if (cur->type == REDIR_TOKEN)
- {
- printf("Parsing error.\n");
return (free(result), NULL);
- }
else
cur = cur->next;
}
if (cur && cur->type == REDIR_TOKEN)
- {
- printf("Parsing error.\n");
return (free(result), NULL);
- }
return (result);
}