diff --git a/README.md b/README.md index 8c795d4..98e3a5b 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,29 @@ test hello test ``` +5. chaque nouvelle ligne doit afficher : +- non pas les characters "> " + +- mais le contenu de la variable PS2 (qui par defaut est la chaine de characater "> ") + +- (au passage, les characaters "$ " affichés a la fin de chaque prompt devraient etre ceux de la variable PS1) + +- [infos ici](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_03) + + +## schema d'execution : +```text + _________________________________________________ +|LOOP: shell_loop() | +| signal(SIGINT, handler) | +| mode interactif -> readline return line_input | +| signal(SIGINT, ignore) | +| lexing | +| parsing | +| execution | +|_________________________________________________| +``` ## understanding some things : @@ -125,6 +147,8 @@ test - [signal in a child process](https://stackoverflow.com/questions/55190460/using-signals-in-a-child-process) - [send signal to process and childs](https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script) - commande utile pour tester les process parents et enfants : while true ; do ps -o pid,pgid,cmd -C bash ; sleep 0.1 ; echo "\n" ; done +- [exit code status](https://tldp.org/LDP/abs/html/exitcodes.html) + ```text | BASH | MINISHELL | diff --git a/headers/minishell_prototypes.h b/headers/minishell_prototypes.h index 064ffce..94aec01 100644 --- a/headers/minishell_prototypes.h +++ b/headers/minishell_prototypes.h @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 02:59:58 by lperrey #+# #+# */ -/* Updated: 2021/11/16 22:58:35 by lperrey ### ########.fr */ +/* Updated: 2021/11/18 13:18:08 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,5 +81,6 @@ char *ft_strdup_quotes(const char *s); // signals.c void sigint_handler_interactive(int signum); +void sigint_handler_heredoc(int signum); #endif diff --git a/srcs/exec_cmd_line.c b/srcs/exec_cmd_line.c index 49c1796..563b312 100644 --- a/srcs/exec_cmd_line.c +++ b/srcs/exec_cmd_line.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */ -/* Updated: 2021/11/17 01:08:38 by lperrey ### ########.fr */ +/* Updated: 2021/11/18 10:28:00 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -173,7 +173,7 @@ int cmd_exec_in_subshell(t_cmd *cmd, t_all *c) return (ft_reti_perror(EXIT_FAILURE, "dup2()")); close_pipeline_fd(c->cmd_arr); if (cmd->builtin_func) - free_exit(c, cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv,c)); + free_exit(c, cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv, c)); else if (execve("/bin/echo", cmd->argv, c->envp) == -1) // WIP, TEST return (ft_reti_perror_io(EXIT_FAILURE, "execve() ", cmd->argv[0])); //else if (execve(cmd->path, cmd->argv, c->envp) == -1) diff --git a/srcs/parsing/redirections/here_doc.c b/srcs/parsing/redirections/here_doc.c index 8fe3dee..29f5164 100644 --- a/srcs/parsing/redirections/here_doc.c +++ b/srcs/parsing/redirections/here_doc.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */ -/* Updated: 2021/11/16 22:29:01 by lperrey ### ########.fr */ +/* Updated: 2021/11/18 13:17:19 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,7 +56,10 @@ static int here_doc_write(char *delimiter, int doc_fd) { char *line; size_t line_count; + struct sigaction signal_action; + signal_action.sa_handler = sigint_handler_heredoc; + sigaction(SIGINT, &signal_action, NULL); line_count = 0; while (1) { diff --git a/srcs/shell_loop.c b/srcs/shell_loop.c index f60c5b0..dae18d9 100644 --- a/srcs/shell_loop.c +++ b/srcs/shell_loop.c @@ -6,15 +6,12 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */ -/* Updated: 2021/11/17 01:30:27 by lperrey ### ########.fr */ +/* Updated: 2021/11/17 15:29:35 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void close_fd(t_cmd *cmd); -void execute_cmd(char **envp, t_cmd **cmd_arr, t_all *c); - void shell_loop(t_all *c) { char *line_input; diff --git a/srcs/signals.c b/srcs/signals.c index b04dfc0..8085804 100644 --- a/srcs/signals.c +++ b/srcs/signals.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/23 18:56:53 by lperrey #+# #+# */ -/* Updated: 2021/11/16 22:58:29 by lperrey ### ########.fr */ +/* Updated: 2021/11/18 13:18:53 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,15 @@ void sigint_handler_interactive(int signum) rl_redisplay(); } +void sigint_handler_heredoc(int signum) +{ + (void)signum; + write(1, "T", 1); + rl_on_new_line(); + rl_replace_line("", 1); + rl_redisplay(); +} + int set_signals_handling(struct sigaction *signal_behaviour) { signal_behaviour->sa_handler = sigint_handler_interactive;