echo
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user