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> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -14,18 +14,15 @@
|
|||
|
||||
int echo_builtin(const char **argv)
|
||||
{
|
||||
int i;
|
||||
int opt;
|
||||
int i;
|
||||
bool newline;
|
||||
|
||||
i = 1;
|
||||
opt = 0;
|
||||
if (argv[1] != NULL)
|
||||
newline = true;
|
||||
if (argv[1] && str_eq(argv[1], "-n"))
|
||||
{
|
||||
if (!ft_strncmp(argv[1], "-n", 3))
|
||||
{
|
||||
opt = 1;
|
||||
i++;
|
||||
}
|
||||
newline = false;
|
||||
i++;
|
||||
}
|
||||
while (argv[i] != NULL)
|
||||
{
|
||||
|
@ -34,7 +31,7 @@ int echo_builtin(const char **argv)
|
|||
printf(" ");
|
||||
i++;
|
||||
}
|
||||
if (opt == 0)
|
||||
printf("\n");
|
||||
if (newline)
|
||||
printf("\n");
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue