diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-10-30 17:05:31 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-10-30 17:05:31 +0100 |
commit | 3051df7c3e57d5645a78d87fa63ff1144fd8699a (patch) | |
tree | 5676fe8501f965cc9e62b8c25791ce1c9a04b0f4 /src/ft_exit.c | |
parent | work work (diff) | |
download | 42-minishell-3051df7c3e57d5645a78d87fa63ff1144fd8699a.tar.gz 42-minishell-3051df7c3e57d5645a78d87fa63ff1144fd8699a.tar.bz2 42-minishell-3051df7c3e57d5645a78d87fa63ff1144fd8699a.tar.xz 42-minishell-3051df7c3e57d5645a78d87fa63ff1144fd8699a.tar.zst 42-minishell-3051df7c3e57d5645a78d87fa63ff1144fd8699a.zip |
exit function works
Diffstat (limited to 'src/ft_exit.c')
-rw-r--r-- | src/ft_exit.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c index e09212c..513b4d1 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -16,7 +16,7 @@ #include <stdlib.h> uint8_t -ft_exit(const char **com) +ft_exit(char **com) { uint8_t i; @@ -26,4 +26,15 @@ ft_exit(const char **com) i++; if (i > 2) return (ft_error(com[0], 1)); + else if (com[1]) + { + i = 0; + while (ft_isdigit(com[1][i])) + i++; + if (i != ft_strlen(com[1])) + return (ft_error(com[0], 255)); + else + exit((uint8_t)ft_atoi(com[1])); + } + exit(0); } |