This commit is contained in:
2024-02-16 21:24:24 +01:00
parent 8d77586948
commit ab5912fe51
5 changed files with 17 additions and 19 deletions

View File

@ -6,7 +6,7 @@
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
# Updated: 2024/02/16 14:26:43 by tomoron ### ########.fr #
# Updated: 2024/02/16 16:28:16 by tomoron ### ########.fr #
# #
# **************************************************************************** #

14
debug.c
View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/15 14:16:47 by tomoron #+# #+# */
/* Updated: 2024/02/16 15:08:40 by marde-vr ### ########.fr */
/* Updated: 2024/02/16 16:34:53 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,10 +21,14 @@ void print_parsed_cmd(t_cmd *cmd)
printf("ARG : %s", cmd->token);
else if (cmd->type == PIPE)
printf("PIPE");
else if (cmd->type == OR)
printf("OR");
else if (cmd->type == AND)
printf("AND");
else if (cmd->type == RED_O)
printf("RED_O");
else if (cmd->type == RED_O_APP)
printf("RED_O_APP");
else if(cmd->type == RED_I)
printf("RED_I");
else if(cmd->type == HERE_DOC)
printf("HERE_DOC");
printf("] ");
cmd = cmd->next;
}

4
main.c
View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/02/15 14:13:57 by tomoron ### ########.fr */
/* Updated: 2024/02/16 16:37:13 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -81,7 +81,7 @@ int main(int argc, char **argv, char **envp)
add_history(command);
parsed_cmd = parse_command(command, env);
free(command);
print_parsed_cmd(parsed_cmd);//debug
//print_parsed_cmd(parsed_cmd);//debug
exec_command(parsed_cmd, env);
free_cmd(parsed_cmd);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
/* Updated: 2024/02/16 16:11:48 by marde-vr ### ########.fr */
/* Updated: 2024/02/16 16:32:33 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,8 +27,6 @@ typedef enum e_token_type
RED_O_APP,
RED_I,
HERE_DOC,
OR,
AND
} t_token_type;
typedef struct s_cmd

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
/* Updated: 2024/02/16 15:09:25 by marde-vr ### ########.fr */
/* Updated: 2024/02/16 16:34:13 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
@ -50,11 +50,7 @@ t_token_type get_token_type(char **command)
while (ft_isspace(**command))
(*command)++;
if ((*command)[0] == '|' && (*command)[1] == '|')
res = OR;
else if ((*command)[0] == '&' && (*command)[1] == '&')
res = AND;
else if ((*command)[0] == '>' && (*command)[1] == '>')
if ((*command)[0] == '>' && (*command)[1] == '>')
res = RED_O_APP;
else if ((*command)[0] == '<' && (*command)[1] == '<')
res = HERE_DOC;
@ -66,7 +62,7 @@ t_token_type get_token_type(char **command)
res = PIPE;
else
res = ARG;
if (res == OR || res == AND || res == RED_O_APP || res == HERE_DOC)
if (res == RED_O_APP || res == HERE_DOC)
(*command) += 2;
if (res == RED_O || res == RED_I || res == PIPE)
(*command)++;