From 26cf50312649c9aa12b9ee461845a7186fd35139 Mon Sep 17 00:00:00 2001 From: tomoron Date: Wed, 24 Apr 2024 21:31:37 +0200 Subject: [PATCH] norme --- srcs/exec_bonus.c | 6 +++--- srcs/input_redirections.c | 8 ++++---- srcs/minishell.h | 3 ++- srcs/output_redirections.c | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index 0d1f281..4acc363 100755 --- a/srcs/exec_bonus.c +++ b/srcs/exec_bonus.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ -/* Updated: 2024/04/24 21:13:53 by marde-vr ### ########.fr */ +/* Updated: 2024/04/24 21:31:10 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -120,9 +120,9 @@ void exec_commands(t_msh *msh) { g_return_code = 0; get_redirections(msh, msh->cmds); - if(msh->in_fd > 2) + if (msh->in_fd > 2) close(msh->in_fd); - if(msh->out_fd > 2) + if (msh->out_fd > 2) close(msh->out_fd); return ; } diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index c3bda4c..95872e2 100755 --- a/srcs/input_redirections.c +++ b/srcs/input_redirections.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */ -/* Updated: 2024/04/24 21:06:43 by marde-vr ### ########.fr */ +/* Updated: 2024/04/24 21:30:46 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ void redirect_input(t_msh *msh, int i, char **cmd_args) } } -void ambiguous_redirect(char *str, t_msh *msh) +void ambiguous_redirect(char *str, t_msh *msh) { ft_printf_fd(2, "minishell: %s: ambiguous redirect\n", str); msh->in_fd = -2; @@ -53,9 +53,9 @@ int open_input_file(t_msh *msh, t_cmd **cur_token) filename = parse_tokens((*cur_token)->value, msh->env); if (!filename) ft_exit(msh, 1); - if(filename->next) + if (filename->next) ambiguous_redirect((*cur_token)->value, msh); - if(!filename->next) + if (!filename->next) msh->in_fd = open(filename->value, O_RDONLY); if (msh->in_fd == -1) { diff --git a/srcs/minishell.h b/srcs/minishell.h index 0570130..7dc11d4 100755 --- a/srcs/minishell.h +++ b/srcs/minishell.h @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */ -/* Updated: 2024/04/24 19:20:23 by tomoron ### ########.fr */ +/* Updated: 2024/04/24 21:30:28 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -170,6 +170,7 @@ int echo(t_token *args); int exit_bt(t_msh *msh); int is_cmd_type(t_cmd *cmd); int is_cmd_char(char c); +void ambiguous_redirect(char *str, t_msh *msh); int cd(t_token *args, t_msh *msh); int pwd(void); diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 93d2e1e..d11a654 100755 --- a/srcs/output_redirections.c +++ b/srcs/output_redirections.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/19 14:09:44 by tomoron #+# #+# */ -/* Updated: 2024/04/24 21:25:27 by tomoron ### ########.fr */ +/* Updated: 2024/04/24 21:31:01 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -83,9 +83,9 @@ int get_out_type(t_msh *msh, t_cmd *cur_cmd) filename = parse_tokens(cur_cmd->value, msh->env); if (!filename) ft_exit(msh, 1); - if(filename->next) + if (filename->next) ambiguous_redirect(cur_cmd->value, msh); - if(!filename->next) + if (!filename->next) ret = open_out_file(msh, &cur_cmd, filename->value); free_token(filename); }