exit status Macro

This commit is contained in:
LuckyLaszlo
2021-11-29 12:42:52 +01:00
parent cb5c2dcb30
commit 33f4878f36
3 changed files with 11 additions and 11 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */
/* Updated: 2021/11/18 13:20:20 by lperrey ### ########.fr */
/* Updated: 2021/11/29 12:35:02 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -42,7 +42,7 @@ int cmd_find_access(t_cmd *cmd, char *path[])
return (0);
if (!cmd->path)
{
cmd->error = 127;
cmd->error = EXIT_CMD_NOT_FOUND;
ft_putstr_fd("minishell: ", 2);
ft_putstr_fd(cmd->argv[0], 2);
ft_putstr_fd(": command not found\n", 2);
@@ -107,7 +107,7 @@ static int handle_access_error(char *file_name)
ft_perror_io("minishell: ", file_name);
errno = tmp;
if (errno == EACCES)
return (127);
return (EXIT_CMD_NOT_FOUND);
return (1);
// 126
// 126 / EXIT_CMD_NOT_EXE
}

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/11/26 21:45:17 by lperrey ### ########.fr */
/* Updated: 2021/11/29 12:38:58 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -93,7 +93,7 @@ static int here_doc_write(char *delimiter, int doc_fd)
line = NULL;
line = readline("> ");
if (g_switch_heredoc_sigint == 1)
return (set_last_exit_status(128 + SIGINT)); // TODO Macro for error
return (set_last_exit_status(EXIT_SIGNAL + SIGINT));
if (!line)
{ // TODO : error print wrapper
ft_putstr_fd("minishell: ", 2);

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/11/29 12:28:25 by lperrey ### ########.fr */
/* Updated: 2021/11/29 12:39:05 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -60,7 +60,7 @@ static int redirect_cmd_input(t_token *t, t_cmd *cmd)
if (cmd->fd_in == -1)
{
ft_perror_io("open() ", t->next->content); // todo error
cmd->error = 42; // WIP error status
cmd->error = EXIT_REDIRECTION;
}
}
else if (t->id == T_DLESS)
@@ -69,9 +69,9 @@ static int redirect_cmd_input(t_token *t, t_cmd *cmd)
if (cmd->fd_in == -1)
{
ft_putstr_fd("minishell: heredoc error\n", 2);
cmd->error = 42; // WIP error status
cmd->error = EXIT_REDIRECTION;
}
else if (cmd->fd_in > 128) // TODO Macro
else if (cmd->fd_in > EXIT_SIGNAL)
return (0);
}
return (1);
@@ -98,7 +98,7 @@ static int redirect_cmd_output(t_token *t, t_cmd *cmd)
if (cmd->fd_out == -1)
{
ft_perror_io("open() ", t->next->content);
cmd->error = 42; // WIP error status
cmd->error = EXIT_REDIRECTION;
}
return (1);
}