AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This commit is contained in:
2024-04-24 14:07:14 +02:00
parent 6977ae4f71
commit 79e440d6b6
5 changed files with 15 additions and 12 deletions

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 10:46:28 by marde-vr #+# #+# */ /* Created: 2024/04/24 10:46:28 by marde-vr #+# #+# */
/* Updated: 2024/04/24 10:49:02 by marde-vr ### ########.fr */ /* Updated: 2024/04/24 14:05:18 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,13 +18,13 @@ void get_redirections(t_msh *msh, t_cmd *cmds)
msh->out_type = 0; msh->out_type = 0;
if (first_is_in_type(cmds)) if (first_is_in_type(cmds))
{ {
if (!get_in_type(msh, cmds)) if (!get_in_type(msh, cmds, cmds, 1))
get_out_type(msh, cmds); get_out_type(msh, cmds);
} }
else else
{ {
if (!get_out_type(msh, cmds)) if (!get_out_type(msh, cmds))
get_in_type(msh, cmds); get_in_type(msh, cmds, cmds, 1);
} }
} }

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
/* Updated: 2024/04/23 16:41:42 by tomoron ### ########.fr */ /* Updated: 2024/04/24 14:04:30 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -62,7 +62,7 @@ int open_input_file(t_msh *msh, t_cmd **cur_token)
return (0); return (0);
} }
int get_in_type(t_msh *msh, t_cmd *tokens) int get_in_type(t_msh *msh, t_cmd *t_strt, t_cmd *tokens, int here_doc)
{ {
t_cmd *cur_token; t_cmd *cur_token;
@ -75,7 +75,8 @@ int get_in_type(t_msh *msh, t_cmd *tokens)
while (cur_token && (cur_token->cmd_type == CMD while (cur_token && (cur_token->cmd_type == CMD
|| cur_token->cmd_type == PAREN)) || cur_token->cmd_type == PAREN))
cur_token = cur_token->next; cur_token = cur_token->next;
if (cur_token && is_input_type(cur_token)) if (cur_token && ((cur_token->cmd_type == HERE_DOC && here_doc)
|| (cur_token->cmd_type == RED_I && !here_doc)))
{ {
msh->in_type = cur_token->cmd_type; msh->in_type = cur_token->cmd_type;
if (open_input_file(msh, &cur_token)) if (open_input_file(msh, &cur_token))
@ -83,7 +84,9 @@ int get_in_type(t_msh *msh, t_cmd *tokens)
} }
if (cur_token && cur_token->next && !is_operand_type(cur_token->next) if (cur_token && cur_token->next && !is_operand_type(cur_token->next)
&& cur_token->cmd_type != PIPE && cur_token->next->cmd_type != PIPE) && cur_token->cmd_type != PIPE && cur_token->next->cmd_type != PIPE)
return (get_in_type(msh, cur_token->next)); return (get_in_type(msh, t_strt, cur_token->next, here_doc));
if (here_doc)
return(get_in_type(msh, t_strt, t_strt, 0));
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/04/24 13:07:14 by tomoron ### ########.fr */ /* Updated: 2024/04/24 13:55:40 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -92,7 +92,7 @@ int init_minishell(t_msh **msh, int argc, char **argv, char **envp)
*msh = ft_calloc(1, sizeof(t_msh)); *msh = ft_calloc(1, sizeof(t_msh));
if (!*msh) if (!*msh)
ft_exit(*msh, 1); exit(1);
(void)argc; (void)argc;
(void)argv; (void)argv;
(*msh)->env = get_env(envp); (*msh)->env = get_env(envp);
@ -118,7 +118,7 @@ int main(int argc, char **argv, char **envp)
{ {
prompt = get_prompt(msh->env); prompt = get_prompt(msh->env);
if (!prompt) if (!prompt)
exit(1); ft_exit(msh, 1);
commands = readline(prompt); commands = readline(prompt);
free(prompt); free(prompt);
add_history(commands); add_history(commands);

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */ /* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
/* Updated: 2024/04/24 10:59:46 by marde-vr ### ########.fr */ /* Updated: 2024/04/24 14:03:39 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -99,7 +99,7 @@ int is_fd_open(int fd);
int get_out_type(t_msh *msh, t_cmd *cmds); int get_out_type(t_msh *msh, t_cmd *cmds);
void exec_commands(t_msh *msh); void exec_commands(t_msh *msh);
void handle_here_doc(t_msh *msh, char *eof); void handle_here_doc(t_msh *msh, char *eof);
int get_in_type(t_msh *msh, t_cmd *tokens); int get_in_type(t_msh *msh, t_cmd *t_strt, t_cmd *tokens, int here_doc);
void signal_handler_interactive(int signum); void signal_handler_interactive(int signum);
int get_token_len(char *cmd, t_env *env); int get_token_len(char *cmd, t_env *env);
void print_syntax_error_bonus(t_cmd *cmd); void print_syntax_error_bonus(t_cmd *cmd);