From 51d631944b78b847c0367b2d88cd87ca278f5e3a Mon Sep 17 00:00:00 2001 From: mdev9 Date: Tue, 5 Mar 2024 08:34:00 +0100 Subject: [PATCH] broke outfile redirects --- srcs/exec.c | 9 +++++---- srcs/main.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/srcs/exec.c b/srcs/exec.c index 0e15fcb..f54736a 100755 --- a/srcs/exec.c +++ b/srcs/exec.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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; diff --git a/srcs/main.c b/srcs/main.c index 97abaa5..ecb2c6d 100755 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }