diff --git a/inc/struct.h b/inc/struct.h index fb8ad6c..835a644 100644 --- a/inc/struct.h +++ b/inc/struct.h @@ -6,7 +6,7 @@ /* By: rpinheir +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/10/16 14:09:15 by rpinheir #+# #+# */ -/* Updated: 2026/10/16 14:42:36 by rpinheir ### ########.ch */ +/* Updated: 2026/10/29 15:35:14 by rpinheir ### ########.ch */ /* */ /* ************************************************************************** */ @@ -15,8 +15,8 @@ # define EXIT_SIGNAL_BASE 128 # define WS_SEP '\001' -# include "libft/libft.h" # include "enum.h" +# include "libft/libft.h" typedef struct s_token { @@ -25,7 +25,7 @@ typedef struct s_token bool is_quoted; char *value; struct s_token *next; -} t_token; +} t_token; typedef struct s_redir { @@ -33,7 +33,7 @@ typedef struct s_redir char *file; struct s_redir *next; bool is_quoted; -} t_redir; +} t_redir; typedef struct s_cmd { @@ -41,13 +41,11 @@ typedef struct s_cmd char *path; t_redir *redirections; struct s_cmd *next; -} t_cmd; +} t_cmd; typedef struct s_shell { - pid_t hereid; int prevfd; - int wread[2]; int cmd_count; pid_t *pids; t_cmd *cmds; @@ -55,6 +53,6 @@ typedef struct s_shell char **env; long long exit_status; bool is_exitting; -} t_shell; +} t_shell; #endif diff --git a/src/builtins/builtin_unset.c b/src/builtins/builtin_unset.c index 8ac5d33..473f294 100644 --- a/src/builtins/builtin_unset.c +++ b/src/builtins/builtin_unset.c @@ -6,7 +6,7 @@ /* By: chguerre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/10/22 21:14:24 by chguerre #+# #+# */ -/* Updated: 2026/10/26 20:48:58 by chguerre ### ########.fr */ +/* Updated: 2026/10/29 15:33:37 by rpinheir ### ########.ch */ /* */ /* ************************************************************************** */ @@ -27,9 +27,9 @@ int filter_envp(t_shell *shell, char **cmd_args) i = 1; while (cmd_args[i]) { - keylen = strlen(cmd_args[i]); - if (shell->env[j] != NULL && ft_strncmp(shell->env[j], - cmd_args[i], keylen) == 0 && shell->env[j][keylen] == '=' ) + keylen = ft_strlen(cmd_args[i]); + if (shell->env[j] != NULL && ft_strncmp(shell->env[j], cmd_args[i], + keylen) == 0 && shell->env[j][keylen] == '=') { finded++; (free(shell->env[j]), shell->env[j] = NULL); diff --git a/src/builtins/builtins.c b/src/builtins/builtins.c index 3fc2e9e..2015ffe 100644 --- a/src/builtins/builtins.c +++ b/src/builtins/builtins.c @@ -6,7 +6,7 @@ /* By: chguerre is_exitting) - (close(0), close(1)); return (code); } diff --git a/src/executor/process.c b/src/executor/process.c index 8884cd3..8f3d698 100644 --- a/src/executor/process.c +++ b/src/executor/process.c @@ -6,7 +6,7 @@ /* By: chguerre prevfd != -1) close(shell->prevfd); - if (i < shell->cmd_count - 1) - { - close(fd[0]); - close(fd[1]); - } + (void)fd; + (void)i; if (shell->pids != NULL) free(shell->pids); ft_strfree(shell->env); @@ -75,9 +72,10 @@ static void run_child(t_shell *shell, int i, int *fd, t_cmd *current) ft_putendl_fd(": command not found", 2); childs_exit(shell, i, fd, 127); } - if ((execve(current->path, current->cmd_args, shell->env)) == -1) - (perror(current->cmd_args[0]), - childs_exit(shell, i, fd, 126 + (errno == ENOENT))); + execve(current->path, current->cmd_args, shell->env); + code = errno; + perror(current->cmd_args[0]); + childs_exit(shell, i, fd, 126 + (code == ENOENT)); } int fork_setup(t_shell *shell, int i, int *fd, t_cmd *current) diff --git a/src/main.c b/src/main.c index 8d30796..7cc129b 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,8 @@ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: chguerre +#+ +:+ +#+ */ +/* By: chguerre +#+ +:+ + +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/10/16 14:06:14 by rpinheir #+# #+# */ /* Updated: 2026/10/22 16:19:18 by rpinheir ### ########.ch */ @@ -71,6 +72,8 @@ void show_prompt(t_shell *shell) else if (line[0] && entry_exec(line, shell) == 1) continue ; } + close(0); + close(1); } int main(int ac, char **av, char **env)