test unitaires a peu pres ok :)

This commit is contained in:
hugogogo
2021-12-03 22:32:07 +01:00
parent 27f8059d8a
commit a288ad473e
26 changed files with 506 additions and 513 deletions

View File

@@ -0,0 +1,43 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <readline/readline.h>
#define WHITE "\001\e[1;37m\002"
#define RESET "\001\e[0m\002"
int main(void)
{
char *prompt;
char *line_input;
//prompt = WHITE"mybash a very long prompt to test the output in case of a redirection in a file> "RESET;
prompt = WHITE"mybash> "RESET;
line_input = NULL;
while (1)
{
if (line_input)
free(line_input);
line_input = readline(prompt);
if (line_input)
{
if (!strncmp(line_input, "echo ", 5))
{
write(1, line_input + 5, strlen(line_input) - 5);
write(1, "\n", 1);
}
}
if (!line_input)
{
write(2, "exit\n", 5);
exit(0);
}
}
/*
prompt = WHITE"mybash a very long prompt to test the output in case of a redirection in a file, style longer than that even> "RESET;
write(1, prompt, strlen(prompt));
write(1, "\n", 1);
*/
return (0);
}