Merge branch 'main' into quinten
This commit is contained in:
commit
8f9c2e33e8
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@ a.out
|
||||
*.d
|
||||
*.o
|
||||
obj/
|
||||
.vscode
|
||||
.minishell_history
|
||||
|
||||
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"minishell.h": "c"
|
||||
}
|
||||
}
|
||||
18
Makefile
18
Makefile
@ -1,12 +1,12 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# #
|
||||
# Updated: 2025/02/04 16:57:05 by qmennen ### ########.fr #
|
||||
# :::::::: #
|
||||
# Makefile :+: :+: #
|
||||
# +:+ #
|
||||
# By: qmennen <qmennen@student.codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# #
|
||||
# Updated: 2025/02/05 16:02:39 by whaffman ######## odam.nl #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -22,7 +22,7 @@ LIBFT = $(LIBFT_PATH)/libft.a
|
||||
|
||||
OBJ_PATH = obj
|
||||
|
||||
VPATH = src:src/enviroment:src/prompt:src/tokenizer
|
||||
VPATH = src:src/enviroment:src/prompt:src/tokenizer:src/utils
|
||||
SOURCES = $(shell basename -a $(shell find $(SRC_PATH) -type f -name "*.c"))
|
||||
|
||||
OBJECTS = $(addprefix $(OBJ_PATH)/, $(SOURCES:.c=.o))
|
||||
@ -31,7 +31,7 @@ DEPENDS = ${OBJECTS:.o=.d}
|
||||
CC = cc
|
||||
RM = rm -rf
|
||||
|
||||
INCLUDES = -I./$(INC_PATH) -I./$(LIBFT_INC_PATH)
|
||||
INCLUDES = -I./$(INC_PATH) -I./$(LIBFT_INC_PATH)
|
||||
CFLAGS = -Wall -Wextra -Werror -fsanitize=address,undefined -MMD
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
@ -6,20 +6,20 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:13:13 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 12:37:14 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 16:28:59 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MINISHELL_H
|
||||
# define MINISHELL_H
|
||||
|
||||
# include "typedef.h"
|
||||
# include "allowed.h"
|
||||
# include "libft.h"
|
||||
# include "typedef.h"
|
||||
# include "enviroment.h"
|
||||
# include "prompt.h"
|
||||
# include "tokenizer.h"
|
||||
|
||||
# include "utils.h"
|
||||
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
@ -36,7 +36,4 @@
|
||||
# define CYAN "\001\033[0;36m\002"
|
||||
# define RESET "\001\033[0m\002"
|
||||
|
||||
|
||||
int ft_isspace(const char c);
|
||||
|
||||
#endif
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:35:35 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 11:54:38 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 17:05:32 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,8 +15,9 @@
|
||||
|
||||
# include "minishell.h"
|
||||
|
||||
typedef struct s_minishell t_minishell; // Forward declaration WHY?
|
||||
|
||||
void print_banner(void);
|
||||
char *ft_prompt(t_minishell *minishell);
|
||||
void ft_write_history(char *line);
|
||||
void ft_load_history(void);
|
||||
|
||||
#endif // PROMPT_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 12:36:08 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 12:36:44 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 15:25:40 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,6 +24,13 @@ typedef enum e_token_type
|
||||
T_ERROR
|
||||
} t_token_type;
|
||||
|
||||
typedef struct s_enviroment
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
struct s_enviroment *next;
|
||||
} t_enviroment;
|
||||
|
||||
typedef struct s_token
|
||||
{
|
||||
t_token_type type;
|
||||
@ -39,18 +46,11 @@ typedef struct s_lexer
|
||||
char current_char;
|
||||
} t_lexer;
|
||||
|
||||
typedef struct s_enviroment
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
struct s_enviroment *next;
|
||||
} t_enviroment;
|
||||
|
||||
typedef struct s_minishell
|
||||
{
|
||||
t_enviroment *enviroment;
|
||||
char *line;
|
||||
t_lexer *lexer;
|
||||
|
||||
t_list *tokens;
|
||||
} t_minishell;
|
||||
|
||||
#endif // TYPEDEF_H
|
||||
|
||||
24
inc/utils.h
Normal file
24
inc/utils.h
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* utils.h :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:06:35 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:23:21 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef UTILS_H
|
||||
# define UTILS_H
|
||||
|
||||
void free_minishell_line(t_minishell *minishell);
|
||||
void free_minishell(t_minishell *minishell);
|
||||
t_minishell *init_minishell(void);
|
||||
void print_banner(void);
|
||||
void print_list(void *content);
|
||||
int cmp_value(t_list *list, char *str);
|
||||
void simple_builtins(t_minishell *minishell);
|
||||
|
||||
#endif // UTILS_H
|
||||
@ -1 +1 @@
|
||||
Subproject commit d76fa9350d07e61e0b2524a411e8aca5151381e4
|
||||
Subproject commit 8072c13f1e064dabf7249e2f148aa6111660dab0
|
||||
@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* parse_enviroment.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 15:52:33 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 15:52:34 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int parse_enviroment(char **envp, t_enviroment **enviroment)
|
||||
@ -5,7 +17,6 @@ int parse_enviroment(char **envp, t_enviroment **enviroment)
|
||||
char **env;
|
||||
|
||||
*enviroment = NULL;
|
||||
|
||||
if (envp == NULL)
|
||||
return (FAILURE);
|
||||
while (*envp != NULL)
|
||||
|
||||
@ -6,13 +6,13 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:13:04 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/04 16:15:52 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 15:52:44 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void print_enviroment(t_enviroment *enviroment)
|
||||
void print_enviroment(t_enviroment *enviroment)
|
||||
{
|
||||
while (enviroment != NULL)
|
||||
{
|
||||
|
||||
70
src/main.c
70
src/main.c
@ -6,75 +6,31 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:19:22 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 11:59:23 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 17:06:47 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
#include "prompt.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void print_banner(void)
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ft_printf("%s\n", BOLD RED "__ ________________________________________________________________ __" GREEN);
|
||||
ft_printf("%s\n", RED "__" GREEN " _______ _____ __ _ _____ _______ _ _ _______ " RED "__");
|
||||
ft_printf("%s\n", RED "__" GREEN " | | | | | \\ | | |______ |_____| |______ | | "RED "__");
|
||||
ft_printf("%s\n", RED "__" GREEN " | | | __|__ | \\_| __|__ ______| | | |______ |_____ |_____ "RED "__");
|
||||
ft_printf("%s\n", RED "__ ________________________________________________________________ __\n" RESET);
|
||||
}
|
||||
|
||||
void print_list(void *content)
|
||||
{
|
||||
t_token *token;
|
||||
token = (t_token *)content;
|
||||
if (token->type == T_ERROR)
|
||||
{
|
||||
printf("An error occurred near position %i\n", token->position);
|
||||
}
|
||||
else
|
||||
ft_printf("%s\n", token->value);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
t_enviroment *enviroment;
|
||||
char *line;
|
||||
t_list *list;
|
||||
t_minishell *minishell;
|
||||
t_minishell *minishell;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
print_banner();
|
||||
minishell = malloc(sizeof(t_minishell));
|
||||
if (!minishell)
|
||||
{
|
||||
perror("failed assigning minishell memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
parse_enviroment(envp, &enviroment);
|
||||
minishell->enviroment = enviroment;
|
||||
ft_load_history();
|
||||
minishell = init_minishell();
|
||||
parse_enviroment(envp, &(minishell->enviroment));
|
||||
while (TRUE)
|
||||
{
|
||||
line = ft_prompt(minishell);
|
||||
if (line != NULL)
|
||||
add_history(line);
|
||||
minishell->lexer = ft_lexer_new(line);
|
||||
list = ft_parse_input(minishell->lexer);
|
||||
ft_lstiter(list, print_list);
|
||||
free(line);
|
||||
if (list != NULL && ft_strncmp(((t_token *)list->content)->value, "clear\0", 6) == 0)
|
||||
printf("\033[2J\033[1;1H");
|
||||
else if (list != NULL && ft_strncmp(((t_token *)list->content)->value, "env\0", 4) == 0)
|
||||
print_enviroment(enviroment);
|
||||
else if (list != NULL && ft_strncmp(((t_token *)list->content)->value, "exit\0", 5) == 0)
|
||||
break;
|
||||
ft_lstclear(&list, ft_clear_tokenlist);
|
||||
ft_lexer_free(minishell->lexer);
|
||||
minishell->line = ft_prompt(minishell);
|
||||
minishell->lexer = ft_lexer_new(minishell->line);
|
||||
minishell->tokens = ft_parse_input(minishell->lexer);
|
||||
simple_builtins(minishell);
|
||||
ft_lstiter(minishell->tokens, print_list);
|
||||
free_minishell_line(minishell);
|
||||
}
|
||||
ft_lstclear(&list, ft_clear_tokenlist);
|
||||
ft_lexer_free(minishell->lexer);
|
||||
// print_enviroment(enviroment);
|
||||
free_enviroment(enviroment);
|
||||
free(minishell);
|
||||
free_minishell(minishell);
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
34
src/prompt/ft_load_history.c
Normal file
34
src/prompt/ft_load_history.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_load_history.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:44:51 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 17:11:59 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void ft_load_history(void)
|
||||
{
|
||||
int fd;
|
||||
char *line;
|
||||
|
||||
fd = open(".minishell_history", O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ;
|
||||
while (TRUE)
|
||||
{
|
||||
line = get_next_line(fd);
|
||||
if (!line)
|
||||
return ;
|
||||
line[ft_strlen(line) - 1] = '\0';
|
||||
if (*line)
|
||||
add_history(line);
|
||||
free(line);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
25
src/prompt/ft_write_history.c
Normal file
25
src/prompt/ft_write_history.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_write_history.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 17:12:17 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 17:12:23 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void ft_write_history(char *line)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(".minishell_history", O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
if (fd < 0)
|
||||
return ;
|
||||
if (*line)
|
||||
ft_putendl_fd(line, fd);
|
||||
close(fd);
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:13:08 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 11:54:12 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/02/05 17:05:12 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -26,14 +26,11 @@ char *get_user(t_enviroment *enviroment)
|
||||
free(str1);
|
||||
str1 = ft_strjoin(str2, RESET "@" GREEN "minishell" RESET ": ");
|
||||
free(str2);
|
||||
|
||||
return (str1);
|
||||
}
|
||||
|
||||
|
||||
char *get_path(t_enviroment *enviroment)
|
||||
{
|
||||
|
||||
char *home;
|
||||
char *temp;
|
||||
char *cwd;
|
||||
@ -68,9 +65,7 @@ char *ft_prompt(t_minishell *minishell)
|
||||
|
||||
cwd = get_path(minishell->enviroment);
|
||||
if (cwd == NULL)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
user = get_user(minishell->enviroment);
|
||||
temp = ft_strjoin(user, cwd);
|
||||
free(user);
|
||||
@ -79,6 +74,10 @@ char *ft_prompt(t_minishell *minishell)
|
||||
free(temp);
|
||||
line = readline(prompt);
|
||||
free(prompt);
|
||||
if (line != NULL)
|
||||
{
|
||||
add_history(line);
|
||||
ft_write_history(line);
|
||||
}
|
||||
return (line);
|
||||
}
|
||||
|
||||
|
||||
24
src/utils/cmp_value.c
Normal file
24
src/utils/cmp_value.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* cmp_value.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:13:19 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:14:51 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmp_value(t_list *list, char *str)
|
||||
{
|
||||
if (list != NULL
|
||||
&& ft_strncmp(
|
||||
((t_token *)list->content)->value,
|
||||
str,
|
||||
ft_strlen(str) + 1) == 0)
|
||||
return (TRUE);
|
||||
return (FALSE);
|
||||
}
|
||||
22
src/utils/free_minishell.c
Normal file
22
src/utils/free_minishell.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* free_minishell.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:03:57 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:04:18 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void free_minishell(t_minishell *minishell)
|
||||
{
|
||||
if (minishell->line)
|
||||
free_minishell_line(minishell);
|
||||
if (minishell->enviroment)
|
||||
free_enviroment(minishell->enviroment);
|
||||
free(minishell);
|
||||
}
|
||||
23
src/utils/free_minishell_line.c
Normal file
23
src/utils/free_minishell_line.c
Normal file
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* free_minishell_line.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:01:44 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:02:07 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void free_minishell_line(t_minishell *minishell)
|
||||
{
|
||||
if (minishell->line)
|
||||
free(minishell->line);
|
||||
if (minishell->lexer)
|
||||
ft_lexer_free(minishell->lexer);
|
||||
if (minishell->tokens)
|
||||
ft_lstclear(&minishell->tokens, ft_clear_tokenlist);
|
||||
}
|
||||
30
src/utils/init_minishell.c
Normal file
30
src/utils/init_minishell.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* init_minishell.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:03:03 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:03:15 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_minishell *init_minishell(void)
|
||||
{
|
||||
t_minishell *minishell;
|
||||
|
||||
minishell = malloc(sizeof(t_minishell));
|
||||
if (!minishell)
|
||||
{
|
||||
perror("failed assigning minishell memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
minishell->enviroment = NULL;
|
||||
minishell->line = NULL;
|
||||
minishell->lexer = NULL;
|
||||
minishell->tokens = NULL;
|
||||
return (minishell);
|
||||
}
|
||||
27
src/utils/print_banner.c
Normal file
27
src/utils/print_banner.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* print_banner.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:04:44 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:05:07 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void print_banner(void)
|
||||
{
|
||||
ft_printf("%s\n", BOLD RED "__ ___________________________"
|
||||
"_____________________________________ __" GREEN);
|
||||
ft_printf("%s\n", RED "__" GREEN " _______ _____ __ _ __"
|
||||
"___ _______ _ _ _______ " RED "__");
|
||||
ft_printf("%s\n", RED "__" GREEN " | | | | | \\ | "
|
||||
" | |______ |_____| |______ | | "RED "__");
|
||||
ft_printf("%s\n", RED "__" GREEN " | | | __|__ | \\_| _"
|
||||
"_|__ ______| | | |______ |_____ |_____ "RED "__");
|
||||
ft_printf("%s\n", RED "__ ________________________________"
|
||||
"________________________________ __\n" RESET);
|
||||
}
|
||||
21
src/utils/print_list.c
Normal file
21
src/utils/print_list.c
Normal file
@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* print_list.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:12:14 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:12:45 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void print_list(void *content)
|
||||
{
|
||||
t_token *token;
|
||||
|
||||
token = (t_token *)content;
|
||||
ft_printf("%s\n", token->value);
|
||||
}
|
||||
26
src/utils/simple_builtins.c
Normal file
26
src/utils/simple_builtins.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* simple_builtins.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */
|
||||
/* Updated: 2025/02/05 16:22:47 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void simple_builtins(t_minishell *minishell)
|
||||
{
|
||||
if (cmp_value(minishell->tokens, "clear"))
|
||||
printf("\033[2J\033[1;1H");
|
||||
else if (cmp_value(minishell->tokens, "env"))
|
||||
print_enviroment(minishell->enviroment);
|
||||
else if (cmp_value(minishell->tokens, "exit"))
|
||||
{
|
||||
free_minishell(minishell);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user