mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
read: read a line with readline and echo it back
This commit is contained in:
parent
08101e295a
commit
a23b639f78
2 changed files with 18 additions and 1 deletions
3
Makefile
3
Makefile
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue