[ADD] echo
This commit is contained in:
parent
823c5b8ac8
commit
4af738e2ee
3 changed files with 46 additions and 2 deletions
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ SRCS = src/
|
||||||
# include directory
|
# include directory
|
||||||
INCLUDES = include/ libtf/ libft/
|
INCLUDES = include/ libtf/ libft/
|
||||||
# .c files in src/ without the extension
|
# .c files in src/ without the extension
|
||||||
CODE = main ask_command error path parse_command exec_command builtin \
|
CODE = main ask_command error path parse_command exec_command builtin echo_builtin\
|
||||||
signals cool_readline
|
signals cool_readline
|
||||||
# directories to 'make'
|
# directories to 'make'
|
||||||
LIBRARIES = libtf libft
|
LIBRARIES = libtf libft
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||||
/* Updated: 2024/06/25 11:38:41 by jschaft ### ########.fr */
|
/* Updated: 2024/06/25 13:31:08 by jschaft ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -21,4 +21,8 @@ bool is_builtin(const char *str);
|
||||||
// Execute the builtin command
|
// Execute the builtin command
|
||||||
int exec_builtin(t_call call, char *const envp[]);
|
int exec_builtin(t_call call, char *const envp[]);
|
||||||
|
|
||||||
|
// Execute echo builtin
|
||||||
|
int echo_builtin(const char **argv);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
40
src/echo_builtin.c
Normal file
40
src/echo_builtin.c
Normal 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);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue