tests ok pour modifier fonctionnement de minishell
This commit is contained in:
29
test_rl_base.c
Normal file
29
test_rl_base.c
Normal file
@@ -0,0 +1,29 @@
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <readline/readline.h>
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
char *line_input;
|
||||
char *prompt;
|
||||
|
||||
line_input = NULL;
|
||||
prompt = strdup("\e[0;31mtest>\e[0m ");
|
||||
while (1)
|
||||
{
|
||||
if (line_input)
|
||||
free(line_input);
|
||||
line_input = readline(prompt);
|
||||
if (line_input && *line_input)
|
||||
{
|
||||
write(1, line_input, strlen(line_input));
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
else if (!line_input)
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user