add: add ctrl + C support, but not work in heredoc
This commit is contained in:
parent
2b66ce5bc3
commit
94f48602d1
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/21 22:26:54 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/21 23:34:37 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -108,7 +108,7 @@ static int ft_own_cmd(t_list **env, t_cmd *cmd)
|
||||
else if (ft_strcmp(cmd->executable, "export") == 0)
|
||||
return_code = (print_export(env, cmd->fd_out));
|
||||
else if (ft_strcmp(cmd->executable, "cd") == 0)
|
||||
return_code = (move_folder(cmd->args[0], cmd->fd_out));
|
||||
return_code = (move_folder(cmd->args[1], cmd->fd_out));
|
||||
/* if (ft_strcmp(cmd->executable, "unset") == 0) */
|
||||
/* return_code = (unset(env, cmd->args, cmd->fd_out)); */
|
||||
else if (ft_strcmp(cmd->executable, "echo") == 0)
|
||||
|
11
main.c
11
main.c
@ -10,10 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libftx/libftx.h"
|
||||
#include "minishell.h"
|
||||
#include "utils/utils.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static char *ft_get_user_input(t_list **env)
|
||||
{
|
||||
@ -104,11 +101,19 @@ int main(int ac, char **av, char **env)
|
||||
|
||||
#else
|
||||
|
||||
void ft_ctrlc(int num)
|
||||
{
|
||||
rl_on_new_line();
|
||||
ft_putchar_fd('\n', 1);
|
||||
rl_redisplay();
|
||||
}
|
||||
|
||||
int main(int ac, char **av, char **env)
|
||||
{
|
||||
t_data data;
|
||||
char *line;
|
||||
|
||||
signal(SIGINT, ft_ctrlc);
|
||||
data.env = init_env(env);
|
||||
if (data.env == NULL)
|
||||
return (1);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/21 13:00:06 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/21 23:40:20 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,7 +18,7 @@ static int ft_quote_verif(const char *str)
|
||||
{
|
||||
if (ft_is_in_quote(str, ft_strlen(str)))
|
||||
{
|
||||
ft_eprintf("minishell: Quote is note closed");
|
||||
ft_eprintf("minishell: Quote is not closed\n");
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
@ -78,7 +78,7 @@ static int ft_special_char_dub(const char *str)
|
||||
if ((y > 2 && (str[i] == '>' || str[i] == '<'))
|
||||
|| (y > 1 && str[i] == '|'))
|
||||
{
|
||||
ft_eprintf("minishell: to many %c in a row", str, str[i]);
|
||||
ft_eprintf("minishell: too many %c in a row\n", str, str[i]);
|
||||
return (1);
|
||||
}
|
||||
i = i + y;
|
||||
@ -96,8 +96,6 @@ int ft_empty_verif(const char *str)
|
||||
i = 0;
|
||||
while (str[i] == ' ')
|
||||
i++;
|
||||
if (str[i] == '\0')
|
||||
ft_eprintf("minishell: %s: command not found \n", str);
|
||||
return (str[i] == '\0');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user