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

1
.gitignore vendored
View file

@ -51,3 +51,4 @@ Module.symvers
Mkfile.old
dkms.conf
objects/
minishell

View file

@ -6,7 +6,7 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2024/03/28 15:17:18 by rparodi ### ########.fr #
# Updated: 2024/03/29 11:45:30 by rparodi ### ########.fr #
# #
# **************************************************************************** #
@ -29,7 +29,8 @@ CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lread
LIB = ./libft/get_next_line.c \
./libft/get_next_line_utils.c
SRC = ./sources/main.c
SRC = ./sources/ft_exit.c\
./sources/main.c
# Objects
OBJDIRNAME = ./objects

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:41:15 by rparodi #+# #+# */
/* Updated: 2024/03/28 15:21:29 by rparodi ### ########.fr */
/* Updated: 2024/03/29 11:42:54 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,6 +27,8 @@
# include <stdarg.h>
# include <readline/readline.h>
# include <readline/history.h>
i32 main(void);
void ft_exit(u8 exit_status);
#endif

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:44:20 by rparodi #+# #+# */
/* Updated: 2024/03/28 15:01:47 by rparodi ### ########.fr */
/* Updated: 2024/03/29 11:44:40 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */

BIN
minishell

Binary file not shown.

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();
}