This commit is contained in:
Loic Deridder
2025-01-15 08:32:26 +01:00
parent d951cc52d7
commit eedfe4a0ee
2 changed files with 36 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
# include <errno.h>
// void echo(char *msg, int flag);
void builtin_echo(char *arg);
void builtin_exit(char *arg, bool depth);
void builtin_pwd(char *arg);

View File

@@ -1,8 +1,37 @@
#include "../../includes/builtins.h"
// void echo(char *msg, int flag)
// {
// printf("%s", msg);
// if (flag == 0)
// printf("\n");
// }
int is_silentchar(char c)
{
if (c == 'n' || c == '-' || c == ' ')
return (1);
else
return (0);
}
int is_silent(char *str)
{
int i;
i = 4;
while (str[i] && str[i] == ' ')
i++;
if (str[i] && str[i] == '-')
{
i++;
if (str[i] && str[i] == 'n')
return (1);
}
return (0);
}
void builtin_echo(char *arg)
{
int i;
i = 4;
while (arg[i] && is_silentchar(arg[i]))
i++;
printf("%s", &arg[i]);
if (!is_silent(arg))
printf("\n");
}