dev: simplify echo's source code
This commit is contained in:
parent
a0f6ecb7a6
commit
a61dac2ec0
1 changed files with 9 additions and 12 deletions
|
@ -6,7 +6,7 @@
|
||||||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/25 13:28:29 by jschaft #+# #+# */
|
/* Created: 2024/06/25 13:28:29 by jschaft #+# #+# */
|
||||||
/* Updated: 2024/06/25 13:55:12 by jschaft ### ########.fr */
|
/* Updated: 2024/06/27 15:51:09 by mcolonna ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -15,18 +15,15 @@
|
||||||
int echo_builtin(const char **argv)
|
int echo_builtin(const char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int opt;
|
bool newline;
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
opt = 0;
|
newline = true;
|
||||||
if (argv[1] != NULL)
|
if (argv[1] && str_eq(argv[1], "-n"))
|
||||||
{
|
{
|
||||||
if (!ft_strncmp(argv[1], "-n", 3))
|
newline = false;
|
||||||
{
|
|
||||||
opt = 1;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
while (argv[i] != NULL)
|
while (argv[i] != NULL)
|
||||||
{
|
{
|
||||||
printf("%s", argv[i]);
|
printf("%s", argv[i]);
|
||||||
|
@ -34,7 +31,7 @@ int echo_builtin(const char **argv)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (opt == 0)
|
if (newline)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue