[ADD] echo

This commit is contained in:
joris schaft 2024-06-25 13:55:51 +02:00
parent 823c5b8ac8
commit 4af738e2ee
3 changed files with 46 additions and 2 deletions

40
src/echo_builtin.c Normal file
View file

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* echo_builtin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/25 13:28:29 by jschaft #+# #+# */
/* Updated: 2024/06/25 13:55:12 by jschaft ### ########.fr */
/* */
/* ************************************************************************** */
#include "include.h"
int echo_builtin(const char **argv)
{
int i;
int opt;
i = 1;
opt = 0;
if (argv[1] != NULL)
{
if (!ft_strncmp(argv[1], "-n", 3))
{
opt = 1;
i++;
}
}
while (argv[i] != NULL)
{
printf("%s", argv[i]);
if (argv[i + 1] != NULL)
printf(" ");
i++;
}
if (opt == 0)
printf("\n");
return (0);
}