des trucs
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 15:04:59 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:22:43 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -48,3 +48,9 @@ void print_parsed_cmd(t_cmd *cmd)
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_msh_struct(t_msh *msh)
|
||||
{
|
||||
printf("in_fd : %d\n", msh->in_fd);
|
||||
printf("out_fd : %d\n", msh->out_fd);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 15:03:01 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:53:51 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -48,7 +48,8 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
||||
if (cmds->cmd_type == CMD)
|
||||
{
|
||||
msh->cmds = parse_command(cmds->value, msh->env);
|
||||
// get_redirections(msh, cmds);
|
||||
get_redirections(msh, cmds);
|
||||
print_msh_struct(msh);
|
||||
print_parsed_cmd(cmds);
|
||||
print_parsed_token(msh->cmds);
|
||||
// exec_commands(msh);
|
||||
@ -109,7 +110,7 @@ void end_execution(t_msh *msh, int cmd_count)
|
||||
if (!g_return_code && WIFEXITED(status))
|
||||
g_return_code = WEXITSTATUS(status);
|
||||
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGQUIT)
|
||||
printf("Quit (core dumped)\n");
|
||||
printf("Quit\n");
|
||||
//TODO: (core dumped) WCOREDUMP
|
||||
free(msh->pids);
|
||||
msh->pids = 0;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/01 20:06:47 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:04:44 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,6 +17,7 @@ void get_here_doc_input(t_msh *msh, char *eof)
|
||||
char *line;
|
||||
|
||||
line = NULL;
|
||||
//TODO: parse eof sans parse les variables
|
||||
while (1)
|
||||
{
|
||||
free(line);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/02 13:28:32 by babonnet ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:40:33 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -29,13 +29,19 @@ void redirect_input(t_msh *msh)
|
||||
|
||||
void open_input_file(t_msh *msh, t_cmd **cur_token)
|
||||
{
|
||||
t_token *filename;
|
||||
|
||||
if ((*cur_token)->cmd_type == HERE_DOC)
|
||||
handle_here_doc(msh, (*cur_token)->next->value);
|
||||
handle_here_doc(msh, (*cur_token)->value);
|
||||
if ((*cur_token)->cmd_type == RED_I)
|
||||
{
|
||||
if (msh->in_fd != 0)
|
||||
close(msh->in_fd);
|
||||
msh->in_fd = open((*cur_token)->next->value, O_RDONLY);
|
||||
filename = parse_command((*cur_token)->value, msh->env);
|
||||
if(!filename)
|
||||
ft_exit(msh, 1);
|
||||
msh->in_fd = open(filename->value, O_RDONLY);
|
||||
free_token(filename);
|
||||
if (msh->in_fd == -1 && !g_return_code)
|
||||
{
|
||||
ft_printf_fd(2, "minishell: %s: ", (*cur_token)->next->value);
|
||||
@ -50,17 +56,14 @@ void get_in_type(t_msh *msh, t_cmd *tokens)
|
||||
t_cmd *cur_token;
|
||||
|
||||
cur_token = tokens;
|
||||
while (cur_token && cur_token->next && cur_token->cmd_type == CMD)
|
||||
while (cur_token && (cur_token->cmd_type == CMD || cur_token->cmd_type == PAREN))
|
||||
cur_token = cur_token->next;
|
||||
if (/*cur_token->type && */cur_token->cmd_type == HERE_DOC || cur_token->cmd_type == RED_I)
|
||||
if (cur_token && is_input_type(cur_token))
|
||||
{
|
||||
msh->in_type = cur_token->cmd_type;
|
||||
open_input_file(msh, &cur_token);
|
||||
}
|
||||
while (cur_token && cur_token->next && cur_token->next->cmd_type == CMD)
|
||||
cur_token = cur_token->next;
|
||||
if (cur_token->next && (cur_token->next->cmd_type == HERE_DOC
|
||||
|| cur_token->next->cmd_type == RED_I))
|
||||
if(cur_token && cur_token->next && !is_operand_type(cur_token->next))
|
||||
get_in_type(msh, cur_token);
|
||||
}
|
||||
|
||||
@ -71,7 +74,7 @@ int first_is_in_type(t_cmd *cmd)
|
||||
cur_token = cmd;
|
||||
while (cur_token && cur_token->cmd_type == CMD && cur_token->next)
|
||||
cur_token = cur_token->next;
|
||||
if (cur_token->cmd_type == RED_I || cur_token->cmd_type == HERE_DOC)
|
||||
if ( is_input_type(cur_token) || cur_token->cmd_type == PIPE)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 14:49:11 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:39:29 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -117,11 +117,16 @@ int first_is_in_type(t_cmd *cmd);
|
||||
int contains_newline(char *str);
|
||||
int check_var_name(char *name);
|
||||
char **get_cmd_args(t_msh *msh);
|
||||
void print_msh_struct(t_msh *msh);
|
||||
char *remove_path(char *token);
|
||||
char *get_var_name(char *str);
|
||||
int exec_builtin(t_msh *msh);
|
||||
void get_cmd_path(t_msh *msh);
|
||||
t_token *free_token(t_token *cmd);
|
||||
int is_input_type(t_cmd *cmd);
|
||||
int is_output_type(t_cmd *cmd);
|
||||
int is_cmd_type(t_cmd *cmd);
|
||||
int is_operand_type(t_cmd *cmd);
|
||||
int set_echoctl(int value);
|
||||
int print_env(t_env *env);
|
||||
t_cmd *free_cmd(t_cmd *cmd);
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* utils2.c :+: :+: :+: */
|
||||
/* utils_bonus.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 17:19:27 by tomoron #+# #+# */
|
||||
/* Updated: 2024/03/28 13:55:48 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/02 17:16:06 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,3 +18,23 @@ t_token *parsing_syntax_error(t_token *res)
|
||||
ft_putstr_fd("minishell: syntax error\n", 2);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int is_input_type(t_cmd *cmd)
|
||||
{
|
||||
return(cmd->cmd_type == HERE_DOC || cmd->cmd_type == RED_I);
|
||||
}
|
||||
|
||||
int is_output_type(t_cmd *cmd)
|
||||
{
|
||||
return(cmd->cmd_type == RED_O || cmd->cmd_type == RED_O_APP);
|
||||
}
|
||||
|
||||
int is_cmd_type(t_cmd *cmd)
|
||||
{
|
||||
return(cmd->cmd_type == CMD || cmd->cmd_type == PAREN);
|
||||
}
|
||||
|
||||
int is_operand_type(t_cmd *cmd)
|
||||
{
|
||||
return(cmd->cmd_type == AND || cmd->cmd_type == OR);
|
||||
}
|
||||
|
Reference in New Issue
Block a user