bugfix, pipeline must continue if expand_redirection() fail
+ ft_perror_io() delete
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 02:59:58 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);
|
void *ft_lstnew_generic(size_t lst_size, size_t content_size);
|
||||||
typedef void *(*t_dup_f)(void *);
|
typedef void *(*t_dup_f)(void *);
|
||||||
void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(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);
|
int ft_reti_perror_io(int ret, char *err_str, char *io_file);
|
||||||
void ft_free_null(void *ptr);
|
void ft_free_null(void *ptr);
|
||||||
char *ft_getenv(char *env_var);
|
char *ft_getenv(char *env_var);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/16 01:57:38 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;
|
int tmp;
|
||||||
|
|
||||||
tmp = errno;
|
tmp = errno;
|
||||||
ft_perror_io("minishell: ", file_name);
|
shell_perror(file_name, "", "", 0);
|
||||||
errno = tmp;
|
errno = tmp;
|
||||||
if (errno == EACCES)
|
if (errno == EACCES)
|
||||||
return (EXIT_CMD_NOT_FOUND);
|
return (EXIT_CMD_NOT_FOUND);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 09:25:35 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);
|
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)
|
int ft_reti_perror_io(int ret, char *err_str, char *io_file)
|
||||||
{
|
{
|
||||||
ft_putstr_fd(err_str, STDERR_FILENO);
|
ft_putstr_fd(err_str, STDERR_FILENO);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/11 18:46:43 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);
|
ret = here_doc_write(delimiter, here_doc);
|
||||||
free(delimiter);
|
free(delimiter);
|
||||||
if (close(here_doc) == -1)
|
if (close(here_doc) == -1)
|
||||||
ft_perror_io("close() ", TMP_HERE_DOC);
|
shell_perror(TMP_HERE_DOC, ": ", "", 0);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
if (unlink(TMP_HERE_DOC) == -1)
|
if (unlink(TMP_HERE_DOC) == -1)
|
||||||
@@ -46,7 +46,7 @@ int here_doc(char *delimiter)
|
|||||||
}
|
}
|
||||||
here_doc = open(TMP_HERE_DOC, O_RDONLY);
|
here_doc = open(TMP_HERE_DOC, O_RDONLY);
|
||||||
if (here_doc == -1)
|
if (here_doc == -1)
|
||||||
ft_perror_io("open() ", TMP_HERE_DOC);
|
shell_perror(TMP_HERE_DOC, ": ", "", 0);
|
||||||
if (unlink(TMP_HERE_DOC) == -1)
|
if (unlink(TMP_HERE_DOC) == -1)
|
||||||
return (ft_reti_perror_io(-1, "unlink() ", TMP_HERE_DOC));
|
return (ft_reti_perror_io(-1, "unlink() ", TMP_HERE_DOC));
|
||||||
return (here_doc);
|
return (here_doc);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/11 18:46:43 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))
|
if (!expand_redirection(t))
|
||||||
{
|
{
|
||||||
cmd->error = EXIT_REDIRECTION;
|
cmd->error = EXIT_REDIRECTION;
|
||||||
return (0);
|
return (1);
|
||||||
}
|
}
|
||||||
cmd->fd_in = open(t->next->content, O_RDONLY);
|
cmd->fd_in = open(t->next->content, O_RDONLY);
|
||||||
if (cmd->fd_in == -1)
|
if (cmd->fd_in == -1)
|
||||||
{
|
{
|
||||||
ft_perror_io("open() ", t->next->content);
|
shell_perror(t->next->content, ": ", "", 0);
|
||||||
cmd->error = EXIT_REDIRECTION;
|
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);
|
cmd->fd_in = here_doc(t->next->content);
|
||||||
if (cmd->fd_in == -1)
|
if (cmd->fd_in == -1)
|
||||||
{
|
{
|
||||||
ft_putstr_fd("minishell: heredoc error\n", STDERR_FILENO);
|
shell_error("heredoc error", ": ", "", 0);
|
||||||
cmd->error = EXIT_REDIRECTION;
|
cmd->error = EXIT_REDIRECTION;
|
||||||
}
|
}
|
||||||
else if (cmd->fd_in > EXIT_SIGNAL)
|
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))
|
if (!expand_redirection(t))
|
||||||
{
|
{
|
||||||
cmd->error = EXIT_REDIRECTION;
|
cmd->error = EXIT_REDIRECTION;
|
||||||
return (0);
|
return (1);
|
||||||
}
|
}
|
||||||
flags = O_WRONLY | O_CREAT;
|
flags = O_WRONLY | O_CREAT;
|
||||||
if (t->id == '>')
|
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);
|
cmd->fd_out = open(t->next->content, flags, S_IRWXU);
|
||||||
if (cmd->fd_out == -1)
|
if (cmd->fd_out == -1)
|
||||||
{
|
{
|
||||||
ft_perror_io("open() ", t->next->content);
|
shell_perror(t->next->content, ": ", "", EXIT_REDIRECTION);
|
||||||
cmd->error = EXIT_REDIRECTION;
|
cmd->error = EXIT_REDIRECTION;
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
|||||||
Reference in New Issue
Block a user