diff --git a/42sh/libft b/42sh/libft index bfc8ca20..6a2672a1 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit bfc8ca207ab4d39f0140322c0f1d368137304a3c +Subproject commit 6a2672a19268c6481525d9aaee5bd35722bbd75a diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index 370e60ac..c7e8aff1 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/02/18 16:48:42 by gwojda ### ########.fr */ +/* Updated: 2017/03/07 15:24:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) ft_dprintf(2, "{red}%s: you have live jobs (running or suspended).{eoc}\n", SHELL_NAME); return (0); } - if (av[1]) + if (av && av[1]) status = ft_atoi(av[1]); else { @@ -38,6 +38,9 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) } ft_save_termios(-1); ft_free_hash_table(); + data_exit(); + if (SH_IS_INTERACTIVE(data_singleton()->opts)) + tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); exit(status); return (0); } diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index e3e1f757..902735ab 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/02/18 13:27:16 by gwojda ### ########.fr */ +/* Updated: 2017/03/07 15:20:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index 0ffbc04e..75f0ae27 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */ -/* Updated: 2017/02/17 15:36:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 15:18:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ int lexer_bquote(t_list **alst, t_lexer *lexer) push(&lexer->stack, lexer->state); return (lexer_lex(alst, lexer)); } - top_state = *(int*)pop(&lexer->stack)->content; + top_state = pop(&lexer->stack); lexer->state = top_state == DQUOTE_BQUOTE ? DQUOTE : DEFAULT; return (lexer_lex(alst, lexer)); } diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index b4aae183..1ab4c90d 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/02/17 14:37:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 15:21:17 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 71713503..97ed8dde 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/02/20 19:13:50 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:24:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -83,6 +83,7 @@ int main(int ac, char **av) t_data *data; data = data_singleton(); + DG();DG(); setlocale(LC_ALL, ""); shell_init(ac, av); // DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s", SH_HAS_JOBC(data->opts)?"ON":"OFF"); @@ -93,5 +94,6 @@ int main(int ac, char **av) } else non_interactive_shell(shell_get_avdata()); + builtin_exit(0); return (0); } diff --git a/42sh/src/main/shell_exit.c b/42sh/src/main/shell_exit.c deleted file mode 100644 index e5735074..00000000 --- a/42sh/src/main/shell_exit.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* shell_exit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */ -/* Updated: 2017/02/20 18:37:46 by wescande ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -void shell_exit(void) -{ -// DG("shell_exit()"); - data_exit(); - if (SH_HAS_JOBC(data_singleton()->opts)) - job_kill_all(); - tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); -} diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index e27ac196..b6f2f19a 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/01/11 17:07:38 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 15:23:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,6 @@ void shell_init(int ac, char **av) data = data_singleton(); data->argc = ac; data->argv = ft_sstrdup(av); - atexit(&shell_exit); shell_get_opts(ac, av); if (SH_IS_INTERACTIVE(data->opts)) {