10 builtin errors less

This commit is contained in:
whaffman 2025-03-03 14:47:00 +01:00
parent 74bc47171f
commit 4e5dc8c816
6 changed files with 17 additions and 15 deletions

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:33:07 by whaffman #+# #+# */
/* Updated: 2025/03/01 14:00:52 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:43:09 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -23,7 +23,7 @@ int builtin_cd(t_minishell *msh, t_command *cmd)
if (env == NULL || env->value == NULL)
{
error_msg(NULL, NULL);
return (FAILURE);
return (EXIT_FAILURE);
}
path = env->value;
}
@ -32,7 +32,7 @@ int builtin_cd(t_minishell *msh, t_command *cmd)
if (chdir(path) == -1)
{
error_msg("cd", path);
return (FAILURE);
return (EXIT_FAILURE);
}
return (SUCCESS);
return (EXIT_SUCCESS);
}

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:32:59 by whaffman #+# #+# */
/* Updated: 2025/03/03 14:08:02 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:44:01 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ int builtin_exit(t_minishell *msh, t_command *cmd)
{
ft_putstr_fd("exit\n", STDERR_FILENO);
ft_putstr_fd("minishell: exit: too many arguments\n", STDERR_FILENO);
return (FAILURE);
return (EXIT_FAILURE);
}
if (ft_count_arr(cmd->args) == 2 && cmd->args[1] != NULL)
{
@ -32,7 +32,7 @@ int builtin_exit(t_minishell *msh, t_command *cmd)
ft_putstr_fd("minishell: exit: ", STDERR_FILENO);
ft_putstr_fd(cmd->args[1], STDERR_FILENO);
ft_putstr_fd(": numeric argument required\n", STDERR_FILENO);
return (FAILURE);
return (EXIT_FAILURE);
}
exit_status = ft_atoi(cmd->args[1]);
}

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:32:53 by whaffman #+# #+# */
/* Updated: 2025/03/03 11:47:34 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:37:13 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -24,7 +24,7 @@ int builtin_export(t_minishell *msh, t_command *cmd)
{
arr = ft_split_safe(msh, cmd->args[i], '=');
if (arr[1] == NULL)
continue ;
return (FAILURE) ;
env = environment_get(msh, arr[0]);
if (env != NULL)
{

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:32:28 by whaffman #+# #+# */
/* Updated: 2025/03/02 22:48:27 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:40:22 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -19,7 +19,9 @@ int builtin_pwd(t_minishell *msh, t_command *cmd)
(void)msh;
(void)cmd;
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return (EXIT_FAILURE);
printf("%s\n", cwd);
free(cwd);
return (SUCCESS);
return (EXIT_SUCCESS);
}

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:12:38 by whaffman #+# #+# */
/* Updated: 2025/02/26 16:06:18 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:38:52 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -25,6 +25,6 @@ int builtin_router(t_minishell *msh, t_command *cmd)
if (!is_builtin(cmd->args[0]))
return (FALSE);
builtin_fn[is_builtin(cmd->args[0])](msh, cmd);
msh->exit_status = builtin_fn[is_builtin(cmd->args[0])](msh, cmd);
return (TRUE);
}

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/20 11:25:43 by whaffman #+# #+# */
/* Updated: 2025/02/26 16:07:21 by whaffman ######## odam.nl */
/* Updated: 2025/03/03 14:42:16 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -23,5 +23,5 @@ int builtin_unset(t_minishell *msh, t_command *cmd)
environment_del(msh, cmd->args[i]);
i++;
}
return (SUCCESS);
return (EXIT_SUCCESS);
}