command->command is too much, print pretty please
This commit is contained in:
parent
dbe5a0d433
commit
09e4befa22
4
Makefile
4
Makefile
@ -6,12 +6,12 @@
|
||||
# By: qmennen <qmennen@student.codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# #
|
||||
# Updated: 2025/03/04 16:05:38 by whaffman ######## odam.nl #
|
||||
# Updated: 2025/03/04 18:26:26 by whaffman ######## odam.nl #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME = minishell
|
||||
FLAGS=-DNOCOLORS -DNOBANNER -DNOPROMPT
|
||||
# FLAGS=-DNOCOLORS -DNOBANNER -DNOPROMPT
|
||||
|
||||
SRC_PATH = src
|
||||
INC_PATH = inc
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/11 14:03:03 by qmennen #+# #+# */
|
||||
/* Updated: 2025/02/28 14:08:11 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:19:23 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
# include "minishell.h"
|
||||
|
||||
t_command *parser_alloc_command(t_minishell *msh, char *cmd);
|
||||
t_command *parser_alloc_command(t_minishell *msh);
|
||||
t_list *parser_get_commands(t_minishell *msh);
|
||||
t_list *parser_get_input_redirects(t_list *list);
|
||||
void parser_create_command(t_minishell *msh,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/05 12:36:08 by whaffman #+# #+# */
|
||||
/* Updated: 2025/03/04 15:25:16 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:11:00 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -58,7 +58,7 @@ typedef struct s_redirect
|
||||
|
||||
typedef struct s_command
|
||||
{
|
||||
char *command;
|
||||
//char *command;
|
||||
char **args;
|
||||
// t_list *environment;
|
||||
t_list *redirect_in;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: marvin <marvin@student.42.fr> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/18 20:06:37 by qmennen #+# #+# */
|
||||
/* Updated: 2025/03/04 15:49:58 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:40:35 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -22,18 +22,20 @@ void print_commands(void *param)
|
||||
command = (t_command *)param;
|
||||
if (!command)
|
||||
return ;
|
||||
printf("command: %s\n", command->command);
|
||||
printf("-- Args: ");
|
||||
printf(BOLD "\n==========================\n" RESET);
|
||||
printf(GREEN BOLD "Command: " RESET "%s\n", command->args[0]);
|
||||
printf(BOLD "-- Args: " RESET);
|
||||
i = 0;
|
||||
while (command->args[i])
|
||||
printf("%s ", command->args[i++]);
|
||||
printf("\n");
|
||||
printf("-- Input redirects:\n");
|
||||
printf(BOLD "-- Input redirects:\n" RESET);
|
||||
ft_lstiter(command->redirect_in, print_redirects);
|
||||
printf("-- Output redirects:\n");
|
||||
printf(BOLD "-- Output redirects:\n" RESET);
|
||||
ft_lstiter(command->redirect_out, print_redirects);
|
||||
printf("-- fd_in: %i\n", command->fd_in);
|
||||
printf("-- fd_out: %i\n", command->fd_out);
|
||||
printf(BOLD "-- fd_in:" RESET " %i\n", command->fd_in);
|
||||
printf(BOLD "-- fd_out:" RESET " %i\n", command->fd_out);
|
||||
printf(BOLD "==========================" RESET "\n");
|
||||
}
|
||||
|
||||
void print_redirects(void *param)
|
||||
@ -49,9 +51,23 @@ void print_redirects(void *param)
|
||||
void token_print(void *param)
|
||||
{
|
||||
t_token *token;
|
||||
const char *token_type[] = {
|
||||
"T_WORD",
|
||||
"T_DQWORD",
|
||||
"T_SQWORD",
|
||||
"T_PIPE",
|
||||
"T_REDIRECT_IN",
|
||||
"T_REDIRECT_OUT",
|
||||
"T_AND",
|
||||
"T_OR",
|
||||
"T_APPEND_OUT",
|
||||
"T_HEREDOC",
|
||||
"T_EOF",
|
||||
"T_ERROR"
|
||||
};
|
||||
|
||||
if (!DEBUG)
|
||||
return ;
|
||||
token = (t_token *)param;
|
||||
printf("token type %i, value %s\n", token->type, token->value);
|
||||
printf( GREEN BOLD "[%s]\t\t" RESET "(%s)\n", token->value, token_type[token->type]);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: willem <willem@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/12 21:25:02 by willem #+# #+# */
|
||||
/* Updated: 2025/03/04 16:03:29 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:18:48 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -47,7 +47,7 @@ int executor_execute_pipeline(t_minishell *msh)
|
||||
last_pid = 0;
|
||||
while (current)
|
||||
{
|
||||
if (is_builtin(((t_command *)current->content)->command) >= 0)
|
||||
if (is_builtin(((t_command *)current->content)->args[0]) >= 0)
|
||||
msh->exit_status = execute_builtin(msh,
|
||||
(t_command *)current->content);
|
||||
else
|
||||
|
||||
@ -6,13 +6,13 @@
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/11 16:18:21 by qmennen #+# #+# */
|
||||
/* Updated: 2025/03/04 15:41:59 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:18:09 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_command *parser_alloc_command(t_minishell *msh, char *cmd)
|
||||
t_command *parser_alloc_command(t_minishell *msh)
|
||||
{
|
||||
t_command *command;
|
||||
|
||||
@ -24,6 +24,5 @@ t_command *parser_alloc_command(t_minishell *msh, char *cmd)
|
||||
command->redirect_out = NULL;
|
||||
// command->environment = NULL;
|
||||
command->n_fds = 0;
|
||||
command->command = cmd;
|
||||
return (command);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/11 14:06:02 by qmennen #+# #+# */
|
||||
/* Updated: 2025/03/04 15:53:59 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/04 18:21:27 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -22,7 +22,6 @@ t_list *parser_get_commands(t_minishell *msh)
|
||||
t_list *command_list;
|
||||
t_list *current;
|
||||
t_command *command;
|
||||
t_token *token;
|
||||
|
||||
command_list = NULL;
|
||||
if (!msh->tokens)
|
||||
@ -30,8 +29,7 @@ t_list *parser_get_commands(t_minishell *msh)
|
||||
current = msh->tokens;
|
||||
while (current)
|
||||
{
|
||||
token = (t_token *) current->content;
|
||||
command = parser_alloc_command(msh, ft_strdup_safe(msh, token->value));
|
||||
command = parser_alloc_command(msh);
|
||||
parser_create_command(msh, command, ¤t);
|
||||
if (! parser_validate_command(command))
|
||||
break ;
|
||||
|
||||
@ -50,8 +50,6 @@ void free_command_list(t_minishell *msh, void *content)
|
||||
t_command *command;
|
||||
|
||||
command = (t_command *)content;
|
||||
if (command->command)
|
||||
free_safe(msh, (void **)&(command->command));
|
||||
if (command->args)
|
||||
free_args(msh, command->args);
|
||||
if (command->redirect_in)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user