read: read a line with readline and echo it back

This commit is contained in:
Khaïs COLIN 2025-02-06 13:58:50 +01:00
parent 08101e295a
commit a23b639f78
No known key found for this signature in database
2 changed files with 18 additions and 1 deletions

View file

@ -3,6 +3,9 @@ DEBUG = -g
ASAN = -fsanitize=address ASAN = -fsanitize=address
TSAN = -fsanitize=thread TSAN = -fsanitize=thread
UBSAN = -fsanitize=undefined UBSAN = -fsanitize=undefined
LDLIBS = \
-lreadline \
ifeq ($(CFLAGS),) ifeq ($(CFLAGS),)
CFLAGS = -Wall -Wextra -Werror $(DEBUG) CFLAGS = -Wall -Wextra -Werror $(DEBUG)
endif endif

View file

@ -6,14 +6,28 @@
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */ /* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */
/* Updated: 2025/02/06 13:46:23 by kcolin ### ########.fr */ /* Updated: 2025/02/06 14:11:37 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <stdbool.h>
#include <readline/readline.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[], char **envp) int main(int argc, char *argv[], char **envp)
{ {
char *line;
(void)argc; (void)argc;
(void)argv; (void)argv;
(void)envp; (void)envp;
line = readline("$ ");
while (line != NULL)
{
printf("%s", line); // FIXME
free(line);
line = readline("$ ");
}
return (0); return (0);
} }