recherche du pbm dans heredoc
This commit is contained in:
@@ -4,40 +4,38 @@
|
||||
#include <string.h>
|
||||
#include <readline/readline.h>
|
||||
|
||||
#define CYAN "\001\e[1;36m\002"
|
||||
#define WHITE "\001\e[1;37m\002"
|
||||
#define RESET "\001\e[0m\002"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *prompt;
|
||||
char *line_input;
|
||||
char *heredoc;
|
||||
char *delimiter;
|
||||
char *here_line;
|
||||
|
||||
//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);
|
||||
line_input = readline(WHITE"mybash> "RESET);
|
||||
if (line_input)
|
||||
{
|
||||
if (!strncmp(line_input, "echo ", 5))
|
||||
heredoc = strstr(line_input, " << ");
|
||||
if (heredoc)
|
||||
{
|
||||
write(1, line_input + 5, strlen(line_input) - 5);
|
||||
write(1, "\n", 1);
|
||||
delimiter = heredoc + strlen(" << ");
|
||||
while(1)
|
||||
{
|
||||
here_line = NULL;
|
||||
here_line = readline(CYAN"> "RESET);
|
||||
if (!strncmp(here_line, delimiter, strlen(here_line) + 1))
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user