broke outfile redirects

This commit is contained in:
mdev9
2024-03-05 08:34:00 +01:00
parent 071331644b
commit 51d631944b
2 changed files with 7 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/03/04 13:40:17 by marde-vr ### ########.fr */
/* Updated: 2024/03/05 08:26:12 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -132,7 +132,7 @@ int get_args_count(t_cmd *cmds)
if (cur_cmd->type == ARG)
count++;
else
cur_cmd = cur_cmd->next->next;
cur_cmd = cur_cmd->next;
}
if (cur_cmd->type == ARG)
count++;
@ -188,6 +188,7 @@ void pipe_child(t_msh *msh, char **cmd_args, int i)
//ft_printf_fd(2, "redirecting input of %s of type %d with fd %d\n", msh->cmds->token, msh->in_type, msh->in_fd);
redirect_input(msh, i);
}
//ft_printf_fd(2, "output of %s of type %d with fd %d\n", msh->cmds->token, msh->out_type, msh->out_fd);
if (msh->out_type == PIPE || msh->out_type == RED_O || msh->out_type == RED_O_APP)
{
//ft_printf_fd(2, "redirecting output of %s of type %d with fd %d\n", msh->cmds->token, msh->out_type, msh->out_fd);
@ -301,7 +302,7 @@ char **get_cmd_args(t_msh *msh)
if (cur_cmd->type == ARG)
{
cmd_args[i] = cur_cmd->token;
ft_printf_fd(2, "%s[%d] = %s\n", msh->cmds->token, i, cur_cmd->token);
//ft_printf_fd(2, "%s[%d] = %s\n", msh->cmds->token, i, cur_cmd->token);
i++;
}
else
@ -391,7 +392,7 @@ void get_out_type(t_msh *msh)
msh->out_type = ARG;
msh->out_fd = 0;
cur_cmd = msh->cmds;
while (cur_cmd && cur_cmd->next && cur_cmd->type == ARG)
while (cur_cmd && cur_cmd->next && cur_cmd->type != ARG) //PIPE?
cur_cmd = cur_cmd->next;
if (!cur_cmd->type)
msh->out_type = ARG;

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/03/04 13:39:15 by marde-vr ### ########.fr */
/* Updated: 2024/03/05 08:02:22 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -100,7 +100,7 @@ int main(int argc, char **argv, char **envp)
msh->cmds = parse_command(command, msh->env);
free(command);
msh->cmds = handle_alias(msh);
print_parsed_cmd(msh->cmds); // debug
//print_parsed_cmd(msh->cmds); // debug
exec_command(msh);
free_cmd(msh->cmds);
}