diff --git a/headers/minishell_prototypes.h b/headers/minishell_prototypes.h index 1178276..c6f57fa 100644 --- a/headers/minishell_prototypes.h +++ b/headers/minishell_prototypes.h @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 02:59:58 by lperrey #+# #+# */ -/* Updated: 2021/12/10 18:46:48 by lperrey ### ########.fr */ +/* Updated: 2021/12/11 20:59:40 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -87,7 +87,6 @@ t_list *ft_lstbeforelast(t_list *lst); void *ft_lstnew_generic(size_t lst_size, size_t content_size); typedef void *(*t_dup_f)(void *); void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(void *)); -void ft_perror_io(char *err_str, char *io_file); int ft_reti_perror_io(int ret, char *err_str, char *io_file); void ft_free_null(void *ptr); char *ft_getenv(char *env_var); diff --git a/srcs/exec/find_access.c b/srcs/exec/find_access.c index 22d44a1..4759b1f 100644 --- a/srcs/exec/find_access.c +++ b/srcs/exec/find_access.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */ -/* Updated: 2021/12/05 16:20:55 by lperrey ### ########.fr */ +/* Updated: 2021/12/11 20:37:43 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -103,7 +103,7 @@ static int handle_access_error(char *file_name) int tmp; tmp = errno; - ft_perror_io("minishell: ", file_name); + shell_perror(file_name, "", "", 0); errno = tmp; if (errno == EACCES) return (EXIT_CMD_NOT_FOUND); diff --git a/srcs/generic.c b/srcs/generic.c index 7e54576..6d2f03e 100644 --- a/srcs/generic.c +++ b/srcs/generic.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 09:25:35 by lperrey #+# #+# */ -/* Updated: 2021/12/11 20:16:36 by lperrey ### ########.fr */ +/* Updated: 2021/12/11 20:59:40 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -200,12 +200,6 @@ void *ft_lstnew_generic(size_t lst_size, size_t content_size) return (elem); } -void ft_perror_io(char *err_str, char *io_file) -{ - ft_putstr_fd(err_str, STDERR_FILENO); - perror(io_file); -} - int ft_reti_perror_io(int ret, char *err_str, char *io_file) { ft_putstr_fd(err_str, STDERR_FILENO); diff --git a/srcs/parsing/redirections/here_doc.c b/srcs/parsing/redirections/here_doc.c index c5d5b73..f705bc8 100644 --- a/srcs/parsing/redirections/here_doc.c +++ b/srcs/parsing/redirections/here_doc.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */ -/* Updated: 2021/12/09 05:31:16 by lperrey ### ########.fr */ +/* Updated: 2021/12/11 20:42:27 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,7 @@ int here_doc(char *delimiter) ret = here_doc_write(delimiter, here_doc); free(delimiter); if (close(here_doc) == -1) - ft_perror_io("close() ", TMP_HERE_DOC); + shell_perror(TMP_HERE_DOC, ": ", "", 0); if (ret != 0) { if (unlink(TMP_HERE_DOC) == -1) @@ -46,7 +46,7 @@ int here_doc(char *delimiter) } here_doc = open(TMP_HERE_DOC, O_RDONLY); if (here_doc == -1) - ft_perror_io("open() ", TMP_HERE_DOC); + shell_perror(TMP_HERE_DOC, ": ", "", 0); if (unlink(TMP_HERE_DOC) == -1) return (ft_reti_perror_io(-1, "unlink() ", TMP_HERE_DOC)); return (here_doc); diff --git a/srcs/parsing/redirections/redirections.c b/srcs/parsing/redirections/redirections.c index e111f56..f89eac0 100644 --- a/srcs/parsing/redirections/redirections.c +++ b/srcs/parsing/redirections/redirections.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */ -/* Updated: 2021/12/11 20:16:31 by lperrey ### ########.fr */ +/* Updated: 2021/12/11 21:15:03 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,12 +55,12 @@ static int redirect_cmd_input(t_token *t, t_cmd *cmd) if (!expand_redirection(t)) { cmd->error = EXIT_REDIRECTION; - return (0); + return (1); } cmd->fd_in = open(t->next->content, O_RDONLY); if (cmd->fd_in == -1) { - ft_perror_io("open() ", t->next->content); + shell_perror(t->next->content, ": ", "", 0); cmd->error = EXIT_REDIRECTION; } } @@ -69,7 +69,7 @@ static int redirect_cmd_input(t_token *t, t_cmd *cmd) cmd->fd_in = here_doc(t->next->content); if (cmd->fd_in == -1) { - ft_putstr_fd("minishell: heredoc error\n", STDERR_FILENO); + shell_error("heredoc error", ": ", "", 0); cmd->error = EXIT_REDIRECTION; } else if (cmd->fd_in > EXIT_SIGNAL) @@ -91,7 +91,7 @@ static int redirect_cmd_output(t_token *t, t_cmd *cmd) if (!expand_redirection(t)) { cmd->error = EXIT_REDIRECTION; - return (0); + return (1); } flags = O_WRONLY | O_CREAT; if (t->id == '>') @@ -101,7 +101,7 @@ static int redirect_cmd_output(t_token *t, t_cmd *cmd) cmd->fd_out = open(t->next->content, flags, S_IRWXU); if (cmd->fd_out == -1) { - ft_perror_io("open() ", t->next->content); + shell_perror(t->next->content, ": ", "", EXIT_REDIRECTION); cmd->error = EXIT_REDIRECTION; } return (1);