/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_b_echo.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include "ft_s_struct.h" #include "ft_u_utils.h" /* TODO: norme, echo $variables (variables are subst when parsing the line), */ /* echo "quoted text", echo 'quoted text', */ /* echo kill\nbackslash\nbut\nnot\nn, echo "quoted\nnew\nlines" */ /* Might need to go full buffer */ uint8_t ft_b_echo(char *args[], t_msh *msh) { const uint64_t argc = ft_get_argc((const char **)args); char **ptr; int8_t nopt; (void)msh; ptr = args; nopt = 0; if (argc >= 1) { if (ft_strncmp(ptr[0], "-n", 2) == 0) { nopt = 1; ptr += 1; } if (argc - nopt >= 1) { ft_printf("%s", *ptr); ptr++; while (*ptr) { ft_printf(" %s", *ptr); ptr++; } } } if (nopt == 0) ft_printf("\n"); return (0); }