small fixes

This commit is contained in:
Loic Deridder
2025-02-18 13:52:56 +01:00
parent f3bf429c07
commit 28b4b0d3bc
5 changed files with 11 additions and 3 deletions

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/27 11:25:25 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/exec.h"
# include "exec/expander.h" # include "exec/expander.h"
# define DEBUG 1 # define DEBUG 0
# ifndef DIO_PATH # ifndef DIO_PATH
# define DIO_PATH "ast.xml" # define DIO_PATH "ast.xml"

View File

@@ -11,6 +11,7 @@
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/minishell.h" #include "../../includes/minishell.h"
#include <stdlib.h>
int count_cmds(t_ast_n **pline) int count_cmds(t_ast_n **pline)
{ {
@@ -94,6 +95,7 @@ int exec_scmd(t_ast_n *node)
pid_t pid; pid_t pid;
int status; int status;
status = 0;
if (!node->cmd) if (!node->cmd)
return (0); return (0);
else if (is_builtin(node->cmd)) else if (is_builtin(node->cmd))

View File

@@ -93,10 +93,12 @@ void read_input(t_ast_n *node, int j)
{ {
char *str; char *str;
int check; int check;
char *tmp;
check = ifhere_remove_quote(node, j); check = ifhere_remove_quote(node, j);
str = get_next_line(node->msh->here_fd, 0); 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) if (!check)
expander_here(&str, node); expander_here(&str, node);
@@ -107,6 +109,7 @@ void read_input(t_ast_n *node, int j)
if (!str) if (!str)
get_next_line(node->msh->here_fd, 1); get_next_line(node->msh->here_fd, 1);
ft_free(&str); ft_free(&str);
ft_free(&tmp);
} }
void here_doc(t_ast_n *node, int i) void here_doc(t_ast_n *node, int i)

View File

@@ -44,6 +44,7 @@ void exec_pchild(int *pipes, int index, t_ast_n *pcmd, int cmds)
dup2(pipes[1], STDOUT_FILENO); dup2(pipes[1], STDOUT_FILENO);
close(pipes[0]); close(pipes[0]);
close(pipes[1]); close(pipes[1]);
pcmd->sh = true;
if (handle_redir(pcmd)) if (handle_redir(pcmd))
{ {
free_child(pcmd->msh); free_child(pcmd->msh);

View File

@@ -17,6 +17,7 @@ int exec_shcmd(t_ast_n *node)
pid_t pid; pid_t pid;
int status; int status;
status = 0;
if (is_builtin(node->cmd)) if (is_builtin(node->cmd))
return (exec_builtin(node)); return (exec_builtin(node));
else else
@@ -92,6 +93,7 @@ int exec_subsh(t_ast_n *node)
pid_t pid; pid_t pid;
int ret; int ret;
status = 0;
pid = fork(); pid = fork();
if (pid == 0) if (pid == 0)
{ {