This commit is contained in:
2024-04-24 21:31:37 +02:00
parent ae81e8dc45
commit 26cf503126
4 changed files with 12 additions and 11 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 ;
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
{

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View File

@ -6,7 +6,7 @@
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}