39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* builtin_echo.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/02/20 11:33:05 by whaffman #+# #+# */
|
|
/* Updated: 2025/03/04 16:16:02 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "minishell.h"
|
|
|
|
int builtin_echo(t_minishell *msh, t_command *cmd)
|
|
{
|
|
int i;
|
|
int n_flag;
|
|
|
|
(void)msh;
|
|
i = 1;
|
|
n_flag = 0;
|
|
if (cmd->args[i] != NULL && ft_strncmp(cmd->args[i], "-n", 3) == 0)
|
|
{
|
|
n_flag = 1;
|
|
i++;
|
|
}
|
|
while (cmd->args[i] != NULL)
|
|
{
|
|
printf("%s", cmd->args[i]);
|
|
if (cmd->args[i + 1] != NULL)
|
|
printf(" ");
|
|
i++;
|
|
}
|
|
if (!n_flag)
|
|
printf("\n");
|
|
return (EXIT_SUCCESS);
|
|
}
|