NIQUE TA GROSSE MÈRE LA SALOPE PUTE PUTE -Camille Chauvet 2004/2023
This commit is contained in:
46
builtins/exit.c
Normal file
46
builtins/exit.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* exit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/24 10:17:59 by erey-bet #+# #+# */
|
||||
/* Updated: 2023/02/24 12:44:05 by erey-bet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
|
||||
static int error(int err, char *reason, char *problem, int fd)
|
||||
{
|
||||
write(fd, "bash: exit: ", 12);
|
||||
if (problem != NULL)
|
||||
{
|
||||
ft_putstr_fd(problem, fd);
|
||||
write(fd, ": ", 2);
|
||||
}
|
||||
ft_putstr_fd(reason, fd);
|
||||
write(fd, "\n", 1);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int ft_exit(char **args, int fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (args[0] == NULL)
|
||||
return (0);
|
||||
i = -1;
|
||||
if (ft_atoi_check(args[0]) == 0)
|
||||
return (error(2, "numeric argument required", args[0], fd));
|
||||
if (args[1] != NULL)
|
||||
return (error(-1, "too many arguments", NULL, fd));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
return(ft_exit(argv + 1, 1));
|
||||
}
|
@ -6,13 +6,13 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/23 17:15:13 by erey-bet ### ########.fr */
|
||||
/* Updated: 2023/02/24 12:32:22 by erey-bet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
|
||||
int error(char *str, int fd)
|
||||
static int error(char *str, int fd)
|
||||
{
|
||||
write(fd, "bash: export: `", 15);
|
||||
write(fd, str, ft_strlen(str));
|
||||
|
Reference in New Issue
Block a user