56 lines
1.5 KiB
C
Raw Normal View History

2024-04-25 11:46:41 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
2024-05-02 15:50:58 +02:00
/* Updated: 2024/05/02 15:47:34 by adjoly ### ########.fr */
2024-04-25 11:46:41 +02:00
/* */
/* ************************************************************************** */
#include <readline/readline.h>
2024-04-30 12:36:16 +02:00
#include <readline/history.h>
2024-04-25 11:46:41 +02:00
#include <stdio.h>
2024-04-27 17:39:26 +02:00
#include <stdlib.h>
2024-04-30 12:36:16 +02:00
#include <stdbool.h>
#include <fcntl.h>
#include "minishell.h"
2024-04-25 11:46:41 +02:00
2024-04-30 12:36:16 +02:00
bool is_str(char *src, char *dst)
2024-04-25 11:46:41 +02:00
{
2024-04-27 17:39:26 +02:00
while (*src && *dst && *src == *dst)
{
src++;
dst++;
}
2024-04-30 12:36:16 +02:00
if (*dst)
return (false);
return (true);
2024-04-25 11:46:41 +02:00
}
int main(int ac, char **av, char **env)
{
char *test;
char **lll;
2024-05-02 15:50:58 +02:00
char *prompt;
2024-04-25 11:46:41 +02:00
(void)ac;
(void)av;
(void)env;
while (1)
{
2024-05-02 15:50:58 +02:00
prompt = get_prompt();
test = readline(prompt);
2024-04-30 12:36:16 +02:00
add_history(test);
2024-04-25 11:46:41 +02:00
lll = ft_split(test, ' ');
2024-04-27 17:39:26 +02:00
if (!*lll)
continue;
if (is_str(test, "exit"))
break;
2024-04-25 11:46:41 +02:00
}
2024-05-02 15:50:58 +02:00
//ft_free("a", &lll);
2024-04-25 11:46:41 +02:00
return (0);
}