Adding the start of the parsing and added the minishell in the git ignore

This commit is contained in:
Raphaël 2024-03-29 11:54:30 +01:00
parent 9a87ad7097
commit 5a24e30c6d
7 changed files with 55 additions and 15 deletions

19
sources/ft_exit.c Normal file
View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */
/* Updated: 2024/03/29 11:42:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/minishell.h"
void ft_exit(u8 exit_status)
{
printf("exit\n");
exit(exit_status);
}

View file

@ -6,30 +6,47 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/03/28 15:20:38 by rparodi ### ########.fr */
/* Updated: 2024/03/29 11:53:25 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/minishell.h"
int ft_check_type_cmd(i8 *cmd)
{
usize i;
i = 0;
while (cmd[i] != '\0')
{
if (cmd[i] == '>')
{
if (cmd[i + 1] == '>')
printf("Have to redirect at the end of the file\n");
else
printf("Have to redirect in the file\n");
}
}
return (1);
}
void ft_take_cmd(void)
{
int i = 0;
char *next_line = NULL;
i32 i = 0;
i8 *user_input = NULL;
while (i < 10000000)
{
next_line = readline("shcat > ");
if (!next_line)
exit(1);
printf("%s\n", next_line);
add_history(next_line);
free(next_line);
user_input = readline("shcat > ");
if (!user_input || strcmp("exit", user_input) == 0)
ft_exit(0);
ft_check_type_cmd(user_input);
add_history(user_input);
free(user_input);
i++;
}
}
int main(void)
i32 main(void)
{
printf("Welcome to our Minishell !\n");
ft_take_cmd();
}