glhf pour les conflits

This commit is contained in:
2024-04-25 13:50:19 +02:00
parent 7f85951e43
commit fe095d4b1f
10 changed files with 31 additions and 21 deletions

View File

@ -6,7 +6,7 @@
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 14:50:15 by tomoron #+# #+# */
/* Updated: 2024/04/24 15:00:00 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:15:19 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,12 +20,14 @@ int check_parens_syntax(t_cmd *cmd, t_cmd *last, t_env *env)
if (last && is_cmd_type(last))
{
ft_putstr_fd("minishell: syntax error\n", 2);
g_return_code = 2;
return (0);
}
parsed_cmd = parsing_bonus(cmd->value);
if (!parsed_cmd)
{
ft_putstr_fd("minishell: syntax error\n", 2);
g_return_code = 2;
return (0);
}
tmp = check_cmds_syntax(parsed_cmd, env);
@ -110,6 +112,9 @@ int check_str_syntax(char *cmd)
cmd++;
}
if (in_quote || in_dquote || parenthesis)
{
g_return_code = 2;
ft_putstr_fd("minishell: syntax error\n", 2);
}
return (!(in_quote || in_dquote || parenthesis));
}

View File

@ -6,7 +6,7 @@
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 14:54:53 by tomoron #+# #+# */
/* Updated: 2024/04/24 18:57:48 by marde-vr ### ########.fr */
/* Updated: 2024/04/25 13:15:00 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,7 @@ void print_syntax_error_bonus(t_cmd *cmd)
if (cmd->cmd_type == CMD || cmd->cmd_type == PAREN)
return ;
ft_printf_fd(2, "minishell : syntax error near unexpected token `");
g_return_code = 2;
if (cmd->cmd_type == AND)
ft_printf_fd(2, "&&");
if (cmd->cmd_type == OR)
@ -34,6 +35,7 @@ int check_tokens_syntax(t_cmd *cmd, t_cmd *last, t_env *env)
if (last && is_cmd_type(last))
{
g_return_code = 2;
ft_putstr_fd("minishell : syntax error\n", 2);
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 10:58:36 by marde-vr #+# #+# */
/* Updated: 2024/04/24 10:59:12 by marde-vr ### ########.fr */
/* Updated: 2024/04/25 13:49:47 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -56,9 +56,11 @@ void sort_env(t_env *env)
void print_env_declare(t_msh *msh, t_env *env_orig)
{
t_env *env;
t_env *start;
env = dup_env(env_orig);
sort_env(env);
start = env;
if (!msh->out_fd)
msh->out_fd = 1;
while (env)

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
/* Updated: 2024/04/24 21:31:10 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:44:26 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -108,7 +108,7 @@ void end_execution(t_msh *msh, int cmd_count)
free(msh->fds);
signal(SIGINT, signal_handler_interactive);
signal(SIGQUIT, signal_handler_interactive);
set_echoctl(0);
//set_echoctl(0);
}
void exec_commands(t_msh *msh)

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
/* Updated: 2024/04/24 19:14:52 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:26:35 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -45,7 +45,7 @@ int exit_bt(t_msh *msh)
else
{
get_exit_bt_return_code(msh, &exit_code);
set_echoctl(msh->echoctl);
//set_echoctl(msh->echoctl);
free_msh(msh);
exit(exit_code);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/04/24 19:10:38 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:40:02 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -82,6 +82,8 @@ t_env *add_shlvl(t_env *env)
else
nb = ft_atoi(tmp);
nb++;
if(nb < 0)
nb = 0;
env = export_set_env(env, ft_strdup("SHLVL"), ft_itoa(nb), 0);
return (env);
}
@ -98,11 +100,12 @@ int init_minishell(t_msh **msh, int argc, char **argv, char **envp)
(*msh)->env = get_env(envp);
(*msh)->env = add_shlvl((*msh)->env);
tcgetattr(1, &t_p);
(*msh)->echoctl = t_p.c_lflag & ECHOCTL;
//(*msh)->echoctl = t_p.c_lflag & ECHOCTL;
rl_catch_signals = 0;
signal(SIGINT, signal_handler_interactive);
signal(SIGQUIT, signal_handler_interactive);
if (set_echoctl(0))
ft_exit(*msh, 1);
//if (set_echoctl(0))
// ft_exit(*msh, 1);
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
/* Updated: 2024/04/24 19:13:12 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:26:52 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -73,7 +73,7 @@ void execute_command(t_msh *msh, char **cmd_args)
env = env_to_char_tab(msh->env);
if (env)
{
set_echoctl(msh->echoctl);
//set_echoctl(msh->echoctl);
if (execve(msh->tokens->value, cmd_args, env))
perror("execve");
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
/* Updated: 2024/04/24 19:14:06 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:46:40 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,13 +17,11 @@ void signal_handler_interactive(int signum)
if (signum == SIGINT)
{
g_return_code = 130;
printf("%s%s^C\n", rl_prompt, rl_line_buffer);
rl_replace_line("", 0);
printf("^C\n");
rl_on_new_line();
rl_redisplay();
}
else if (signum == SIGQUIT)
printf("%s%s", rl_prompt, rl_line_buffer);
}
void *here_doc_variables(int write, void *data)
@ -43,7 +41,6 @@ void signal_handler_here_doc(int signum)
if (signum == SIGINT)
{
printf("%s%s^C\n", rl_prompt, rl_line_buffer);
msh = here_doc_variables(0, 0);
close(msh->in_fd);
ft_exit(msh, 1);

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
/* Updated: 2024/04/24 19:14:28 by tomoron ### ########.fr */
/* Updated: 2024/04/25 13:44:14 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
void ft_exit(t_msh *msh, int exit_code)
{
set_echoctl(msh->echoctl);
//set_echoctl(msh->echoctl);
free_msh(msh);
exit(exit_code);
}

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/27 17:19:27 by tomoron #+# #+# */
/* Updated: 2024/04/24 18:59:26 by marde-vr ### ########.fr */
/* Updated: 2024/04/25 13:13:55 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,6 +16,7 @@ t_token *parsing_syntax_error(t_token *res)
{
free_token(res);
ft_putstr_fd("minishell: syntax error\n", 2);
g_return_code = 0;
return ((void *)1);
}