shell_script()
+ reset "rl_event_hook" to NULL after here_doc() + split init.c in multiple files + submodule minishell_tests
This commit is contained in:
@@ -6,14 +6,53 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/26 23:47:44 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/29 12:43:44 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/18 05:29:27 by lperrey ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void shell_script(t_all *c) // WIP
|
||||
static char *read_input_script(t_all *c);
|
||||
|
||||
void shell_script(t_all *c)
|
||||
{
|
||||
ft_putstr_fd("Shell Script Placeholder\n", 1);
|
||||
exit_free(c, EXIT_SUCCESS);
|
||||
char *line_input;
|
||||
|
||||
line_input = NULL;
|
||||
while (1)
|
||||
{
|
||||
free(line_input);
|
||||
line_input = read_input_script(c);
|
||||
if (line_input && *line_input)
|
||||
{
|
||||
c->token_list = lexing(line_input);
|
||||
ft_free_null(&line_input);
|
||||
if (!c->token_list)
|
||||
break ;
|
||||
c->pipeline = parsing(c->token_list);
|
||||
ft_lstclear((t_list **)&c->token_list, free);
|
||||
if (!c->pipeline)
|
||||
break ;
|
||||
exec_cmd_line(c);
|
||||
}
|
||||
}
|
||||
free(line_input);
|
||||
exit_free(c, get_last_exit_status());
|
||||
}
|
||||
|
||||
static char *read_input_script(t_all *c)
|
||||
{
|
||||
char *line_input;
|
||||
struct sigaction signal_behaviour;
|
||||
|
||||
ft_bzero(&signal_behaviour, sizeof signal_behaviour);
|
||||
signal_behaviour.sa_handler = sigint_handler_interactive;
|
||||
sigaction(SIGINT, &signal_behaviour, NULL);
|
||||
rl_event_hook = NULL;
|
||||
line_input = readline(NULL);
|
||||
signal_behaviour.sa_handler = SIG_IGN;
|
||||
sigaction(SIGINT, &signal_behaviour, NULL);
|
||||
if (!line_input)
|
||||
exit_free(c, get_last_exit_status());
|
||||
return (line_input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user