From 2dff0d522812e7e1e32f87e6edf21100e268e0ed Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 30 Oct 2019 18:16:42 +0100 Subject: work work --- src/ft_error.c | 10 +++++----- src/ft_exec.c | 12 ++++++++++-- src/main.c | 5 ----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/ft_error.c b/src/ft_error.c index 5d0234f..7a2b61a 100644 --- a/src/ft_error.c +++ b/src/ft_error.c @@ -15,15 +15,15 @@ #include int -ft_error(const char *com, int errno) +ft_error(const char *com, int err) { ft_putstr("joe-sh: "); ft_putstr(com); - if (errno == 1) + if (err == 1) ft_putendl(": too many arguments"); - else if (errno == 127) + else if (err == 127) ft_putendl(": command not found"); - else if (errno == 255) + else if (err == 255) ft_putendl(": numeric argument required"); - return (errno); + return (err); } diff --git a/src/ft_exec.c b/src/ft_exec.c index 0c950e4..7177f5b 100644 --- a/src/ft_exec.c +++ b/src/ft_exec.c @@ -1,10 +1,18 @@ #include #include -#include +#include int ft_exec(char **app) { - (void)app; + uint8_t i; + + i = 0; + while (app[i]) + i++; + if (i < 2) + return (execve(app[0] + 2, NULL, NULL)); + else + return (execve(app[0] + 2, &app[1], NULL)); return (0); } diff --git a/src/main.c b/src/main.c index cfd3587..bcdb4c2 100644 --- a/src/main.c +++ b/src/main.c @@ -43,11 +43,6 @@ int { if (c == '\n') break ; - if (i > 128) - { - write(1, "Command too long!\n", 18); - return (2); - } arg[i] = c; i++; } -- cgit v1.2.3