diff options
Diffstat (limited to 'src/ft_echo.c')
-rw-r--r-- | src/ft_echo.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/ft_echo.c b/src/ft_echo.c index 66d803f..08fac36 100644 --- a/src/ft_echo.c +++ b/src/ft_echo.c @@ -12,21 +12,16 @@ ft_echo(char **com, uint8_t n) fd = 1; if (!com[1]) ft_putendl_fd("", fd); - else if (ft_strncmp(com[1], "-n", ft_strlen(com[1]))) + else if (!ft_strncmp(com[1], "-n", ft_strlen(com[1]))) + i = 2; + while (i < n) { - while (i < n) - { - ft_putendl_fd(com[i], fd); - i++; - } - } - else - { - while (i < n) - { - ft_putstr_fd(com[i], fd); - i++; - } + ft_putstr_fd(com[i], fd); + if (i != n - 1) + ft_putchar_fd(' ', fd); + i++; } + if (ft_strncmp(com[1], "-n", ft_strlen(com[1]))) + ft_putchar_fd('\n', fd); return (0); } |