diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index 1e583fd..2fd2559 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/23 14:45:42 by tomoron ### ########.fr */ +/* Updated: 2024/04/23 16:32:16 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,7 @@ void exec_command_bonus(t_msh *msh, char *cmd_str) if (!cmd_str) return ; cmds = parsing_bonus(cmd_str); - tmp = check_cmds_syntax(cmds); + tmp = check_cmds_syntax(cmds, msh->env); if (tmp) { print_syntax_error_bonus(tmp); diff --git a/srcs/minishell.h b/srcs/minishell.h index b3183cf..87ddb65 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/23 13:44:49 by tomoron ### ########.fr */ +/* Updated: 2024/04/23 16:31:56 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -118,7 +118,7 @@ void parse_var(t_msh *msh, char *line); void print_parsed_token(t_token *cmd);//debug int get_var_name_len(char *command); void handle_minishellrc(t_msh *msh); -t_cmd *check_cmds_syntax(t_cmd *cmds); +t_cmd *check_cmds_syntax(t_cmd *cmds, t_env *env); char *get_tmp_file_name(t_msh *msh); int get_args_count(t_token *cmds); char **env_to_char_tab(t_env *env); diff --git a/srcs/parsing_bonus.c b/srcs/parsing_bonus.c index 50fa8c7..cfc6a18 100755 --- a/srcs/parsing_bonus.c +++ b/srcs/parsing_bonus.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */ -/* Updated: 2024/04/23 16:00:00 by tomoron ### ########.fr */ +/* Updated: 2024/04/23 16:34:20 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -142,7 +142,7 @@ void print_syntax_error_bonus(t_cmd *cmd) } -int check_parens_syntax(t_cmd *cmd, t_cmd *last) +int check_parens_syntax(t_cmd *cmd, t_cmd *last, t_env *env) { t_cmd *parsed_cmd; t_cmd *tmp; @@ -158,14 +158,14 @@ int check_parens_syntax(t_cmd *cmd, t_cmd *last) ft_putstr_fd("minishell: syntax error\n", 2); return(0); } - tmp = check_cmds_syntax(parsed_cmd); + tmp = check_cmds_syntax(parsed_cmd, env); if(tmp) print_syntax_error_bonus(tmp); free_cmd(parsed_cmd); return(tmp == 0); } -int check_tokens_syntax(t_cmd *cmd, t_cmd *last) +int check_tokens_syntax(t_cmd *cmd, t_cmd *last, t_env *env) { t_token *token; @@ -174,29 +174,29 @@ int check_tokens_syntax(t_cmd *cmd, t_cmd *last) ft_putstr_fd("minishell : syntax error\n", 2); return (0); } - token = parse_cmds_to_token(cmd, 0); + token = parse_cmds_to_token(cmd, env); if (!token) return (0); free_token(token); return (1); } -int check_cmd_type_syntax(t_cmd *cmds, t_cmd *last) +int check_cmd_type_syntax(t_cmd *cmds, t_cmd *last, t_env *env) { if (cmds->cmd_type == CMD) { - if (!check_tokens_syntax(cmds, last)) + if (!check_tokens_syntax(cmds, last, env)) return (0); } else if(cmds->cmd_type == PAREN) { - if(!check_parens_syntax(cmds, last)) + if(!check_parens_syntax(cmds, last, env)) return(0); } return(1); } -t_cmd *check_cmds_syntax(t_cmd *cmds) +t_cmd *check_cmds_syntax(t_cmd *cmds, t_env *env) { t_cmd *last; @@ -205,7 +205,7 @@ t_cmd *check_cmds_syntax(t_cmd *cmds) if (!is_operand_type(cmds) && cmds->cmd_type != PIPE && cmds->value == 0) return (cmds); last = cmds; - if(is_cmd_type(cmds) && !check_cmd_type_syntax(cmds, 0)) + if(is_cmd_type(cmds) && !check_cmd_type_syntax(cmds, 0, env)) return(cmds); cmds = cmds->next; while (cmds) @@ -216,7 +216,7 @@ t_cmd *check_cmds_syntax(t_cmd *cmds) if (is_operand_type(cmds) || cmds->cmd_type == PIPE) if ((!is_cmd_type(last) && !is_output_type(last) && !is_input_type(last)) || !cmds->next || (!is_cmd_type(cmds->next) && !is_output_type(cmds->next) && !is_input_type(cmds->next))) return (cmds); - if(is_cmd_type(cmds) && !check_cmd_type_syntax(cmds, last)) + if(is_cmd_type(cmds) && !check_cmd_type_syntax(cmds, last, env)) return(cmds); last = cmds; cmds = cmds->next;