From 28b4b0d3bc7022541d8875a58b5fff28ca3623e4 Mon Sep 17 00:00:00 2001 From: Loic Deridder Date: Tue, 18 Feb 2025 13:52:56 +0100 Subject: [PATCH] small fixes --- includes/minishell.h | 4 ++-- srcs/execution/exec_cmd.c | 2 ++ srcs/execution/exec_heredoc.c | 5 ++++- srcs/execution/exec_pline.c | 1 + srcs/execution/exec_subsh.c | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/minishell.h b/includes/minishell.h index 48c03ef..1b326ec 100644 --- a/includes/minishell.h +++ b/includes/minishell.h @@ -6,7 +6,7 @@ /* By: lderidde +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/27 11:25:25 by lderidde #+# #+# */ -/* Updated: 2025/02/18 09:08:46 by lderidde ### ########.fr */ +/* Updated: 2025/02/18 13:06:08 by lderidde ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ # include "exec/exec.h" # include "exec/expander.h" -# define DEBUG 1 +# define DEBUG 0 # ifndef DIO_PATH # define DIO_PATH "ast.xml" diff --git a/srcs/execution/exec_cmd.c b/srcs/execution/exec_cmd.c index dabe828..58ca483 100644 --- a/srcs/execution/exec_cmd.c +++ b/srcs/execution/exec_cmd.c @@ -11,6 +11,7 @@ /* ************************************************************************** */ #include "../../includes/minishell.h" +#include int count_cmds(t_ast_n **pline) { @@ -94,6 +95,7 @@ int exec_scmd(t_ast_n *node) pid_t pid; int status; + status = 0; if (!node->cmd) return (0); else if (is_builtin(node->cmd)) diff --git a/srcs/execution/exec_heredoc.c b/srcs/execution/exec_heredoc.c index 060c205..69cbeda 100644 --- a/srcs/execution/exec_heredoc.c +++ b/srcs/execution/exec_heredoc.c @@ -93,10 +93,12 @@ void read_input(t_ast_n *node, int j) { char *str; int check; + char *tmp; check = ifhere_remove_quote(node, j); str = get_next_line(node->msh->here_fd, 0); - while (str && ft_strncmp(str, node->files[j], -1) != 0) + tmp = ft_strjoin(node->files[j], "\n"); + while (str && ft_strncmp(str, tmp, -1) != 0) { if (!check) expander_here(&str, node); @@ -107,6 +109,7 @@ void read_input(t_ast_n *node, int j) if (!str) get_next_line(node->msh->here_fd, 1); ft_free(&str); + ft_free(&tmp); } void here_doc(t_ast_n *node, int i) diff --git a/srcs/execution/exec_pline.c b/srcs/execution/exec_pline.c index 54bf139..6a53547 100644 --- a/srcs/execution/exec_pline.c +++ b/srcs/execution/exec_pline.c @@ -44,6 +44,7 @@ void exec_pchild(int *pipes, int index, t_ast_n *pcmd, int cmds) dup2(pipes[1], STDOUT_FILENO); close(pipes[0]); close(pipes[1]); + pcmd->sh = true; if (handle_redir(pcmd)) { free_child(pcmd->msh); diff --git a/srcs/execution/exec_subsh.c b/srcs/execution/exec_subsh.c index b881d66..5af794c 100644 --- a/srcs/execution/exec_subsh.c +++ b/srcs/execution/exec_subsh.c @@ -17,6 +17,7 @@ int exec_shcmd(t_ast_n *node) pid_t pid; int status; + status = 0; if (is_builtin(node->cmd)) return (exec_builtin(node)); else @@ -92,6 +93,7 @@ int exec_subsh(t_ast_n *node) pid_t pid; int ret; + status = 0; pid = fork(); if (pid == 0) {