summaryrefslogtreecommitdiffstats
path: root/src/b_echo.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-30 17:20:35 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-30 17:20:35 +0200
commit33e9550f7ad34bd67e0989b5da6da2bf0a5671c0 (patch)
treebe3dfbc8b49a2464146f9aca0dcdfa8384a27aa5 /src/b_echo.c
parentUpdate (diff)
download42-minishell-33e9550f7ad34bd67e0989b5da6da2bf0a5671c0.tar.gz
42-minishell-33e9550f7ad34bd67e0989b5da6da2bf0a5671c0.tar.bz2
42-minishell-33e9550f7ad34bd67e0989b5da6da2bf0a5671c0.tar.xz
42-minishell-33e9550f7ad34bd67e0989b5da6da2bf0a5671c0.tar.zst
42-minishell-33e9550f7ad34bd67e0989b5da6da2bf0a5671c0.zip
Normed b_echo
Diffstat (limited to 'src/b_echo.c')
-rw-r--r--src/b_echo.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/b_echo.c b/src/b_echo.c
index b3d4953..f931f36 100644
--- a/src/b_echo.c
+++ b/src/b_echo.c
@@ -18,8 +18,18 @@
#include "s_struct.h"
#include "u_utils.h"
-uint8_t
- b_echo(char *args[], t_msh *msh)
+static void b_print_content(char *ptr[])
+{
+ ft_printf("%s", *ptr);
+ ptr++;
+ while (*ptr != NULL)
+ {
+ ft_printf(" %s", *ptr);
+ ptr++;
+ }
+}
+
+uint8_t b_echo(char *args[], t_msh *msh)
{
const uint64_t argc = u_builtins_get_argc((const char **)args);
char **ptr;
@@ -36,15 +46,9 @@ uint8_t
ptr += 1;
}
if (argc - nopt >= 1)
- {
- ft_printf("%s", *ptr);
- ptr++;
- while (*ptr)
- {
- ft_printf(" %s", *ptr);
- ptr++;
- }
- }
+ {
+ b_print_content(ptr);
+ }
}
if (nopt == 0)
ft_printf("\n");