From b45a04e62241b1939ae4328b63c716cfc8c89b0c Mon Sep 17 00:00:00 2001 From: tom moron Date: Sun, 5 May 2024 20:07:53 +0200 Subject: [PATCH 1/3] fix exit quand output ambiguous redirect --- srcs/output_redirections.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 2a23038..5c3e14b 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/05/03 14:07:43 by marde-vr ### ########.fr */ +/* Updated: 2024/05/05 20:06:43 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,10 @@ void get_out_file(t_msh *msh, t_cmd *cur_cmd, int *ret) msh->out_type = cur_cmd->cmd_type; if (ft_strchr(cur_cmd->value, '$')) + { ambiguous_redirect(cur_cmd->value, msh); + return ; + } filename = parse_tokens(cur_cmd->value, msh->env); if (!filename) ft_exit(msh, 1); From 43e4d054b5bc9e34cca20283dd29bde128db71cb Mon Sep 17 00:00:00 2001 From: tom moron Date: Sun, 5 May 2024 20:26:52 +0200 Subject: [PATCH 2/3] fix exit when variable on input redirection and invalid read --- srcs/input_redirections.c | 5 ++++- srcs/parsing_var.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index 2765e77..7c2268e 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/05/03 14:11:52 by marde-vr ### ########.fr */ +/* Updated: 2024/05/05 20:10:03 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,10 @@ int open_input_redirection_file(t_msh *msh, t_cmd **cur_token) if (msh->in_fd != 0) close(msh->in_fd); if (ft_strchr((*cur_token)->value, '$')) + { ambiguous_redirect((*cur_token)->value, msh); + return (1); + } filename = parse_tokens((*cur_token)->value, msh->env); if (!filename) ft_exit(msh, 1); diff --git a/srcs/parsing_var.c b/srcs/parsing_var.c index 88727b9..bab3a61 100755 --- a/srcs/parsing_var.c +++ b/srcs/parsing_var.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */ -/* Updated: 2024/05/04 14:11:54 by tomoron ### ########.fr */ +/* Updated: 2024/05/05 20:21:43 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,10 @@ int get_var_len(char **command, t_env *env) (*command)++; if (**command == '\'' || **command == '"') + { + (*command)--; return(0); + } if (!**command) return (1); if (!ft_isalnum(**command) && **command != '_' && **command != '?') From 28efa75b391336267614bf8733c0aad50bc576eb Mon Sep 17 00:00:00 2001 From: tom moron Date: Sun, 5 May 2024 20:38:05 +0200 Subject: [PATCH 3/3] fix autre invalid read --- srcs/parsing_var.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/srcs/parsing_var.c b/srcs/parsing_var.c index bab3a61..54eb6f6 100755 --- a/srcs/parsing_var.c +++ b/srcs/parsing_var.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */ -/* Updated: 2024/05/05 20:21:43 by tomoron ### ########.fr */ +/* Updated: 2024/05/05 20:36:59 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,10 +31,13 @@ int get_var_len(char **command, t_env *env) if (**command == '\'' || **command == '"') { (*command)--; - return(0); + return (0); } if (!**command) + { + (*command)--; return (1); + } if (!ft_isalnum(**command) && **command != '_' && **command != '?') return (2); if (**command == '?')