add: exit cmd

This commit is contained in:
Camille Chauvet
2023-02-24 13:13:11 +01:00
parent 3d66fbe9a9
commit 9f0b0f5422
4 changed files with 25 additions and 15 deletions

View File

@ -14,7 +14,7 @@
static int error(int err, char *reason, char *problem, int fd)
{
write(fd, "bash: exit: ", 12);
ft_putstr_fd("minishell: exit ", fd);
if (problem != NULL)
{
ft_putstr_fd(problem, fd);
@ -36,11 +36,11 @@ int ft_exit(char **args, int fd)
return (error(2, "numeric argument required", args[0], fd));
if (args[1] != NULL)
return (error(-1, "too many arguments", NULL, fd));
return (0);
return (ft_atoi(args[0]));
}
int main(int argc, char *argv[])
{
(void)argc;
return(ft_exit(argv + 1, 1));
}
/* int main(int argc, char *argv[]) */
/* { */
/* (void)argc; */
/* return(ft_exit(argv + 1, 1)); */
/* } */

View File

@ -10,6 +10,8 @@
/* */
/* ************************************************************************** */
#include "../minishell.h"
int error(char *str, int fd)
{
write(fd, "bash: unset: `", 14);