issue #50 done

This commit is contained in:
Jack Halford 2017-03-08 13:07:46 +01:00
parent 8a46d9fe2a
commit e711ffc927
12 changed files with 22 additions and 49 deletions

View file

@ -250,7 +250,6 @@ main/data_singleton.c\
main/ft_putast.c\ main/ft_putast.c\
main/instruction_free.c\ main/instruction_free.c\
main/main.c\ main/main.c\
main/shell_exit.c\
main/shell_get_avdata.c\ main/shell_get_avdata.c\
main/shell_get_opts.c\ main/shell_get_opts.c\
main/shell_init.c\ main/shell_init.c\

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
/* Updated: 2017/03/07 18:36:00 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:00:10 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -54,12 +54,12 @@
# define TOUCHE_F5 892427035 # define TOUCHE_F5 892427035
# define TOUCHE_F6 925981467 # define TOUCHE_F6 925981467
# define IS_QUOTES (1 << 0) /* # define IS_QUOTES (1 << 0) */
# define IS_BQUOTES (1 << 1) /* # define IS_BQUOTES (1 << 1) */
# define IS_DQUOTES (1 << 2) /* # define IS_DQUOTES (1 << 2) */
# define IS_BSLASH (1 << 3) /* # define IS_BSLASH (1 << 3) */
# define IS_ACCOLADE (1 << 4) /* # define IS_ACCOLADE (1 << 4) */
# define IS_BRACKET (1 << 5) /* # define IS_BRACKET (1 << 5) */
# define STR data_singleton()->line.input # define STR data_singleton()->line.input
# define POS data_singleton()->line.pos # define POS data_singleton()->line.pos

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/02/18 16:48:42 by gwojda ### ########.fr */ /* Updated: 2017/03/08 13:04:52 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,15 +29,15 @@ 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); ft_dprintf(2, "{red}%s: you have live jobs (running or suspended).{eoc}\n", SHELL_NAME);
return (0); return (0);
} }
if (av[1]) if (av && av[1])
status = ft_atoi(av[1]); status = ft_atoi(av[1]);
else else
{ status = ft_atoi(ft_getenv(data_singleton()->env, "?"));
/* status = ft_atoi(ft_getenv(data_singleton()->env, "?")); */
status = 0;
}
ft_save_termios(-1); ft_save_termios(-1);
ft_free_hash_table(); ft_free_hash_table();
data_exit();
if (SH_IS_INTERACTIVE(data_singleton()->opts))
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
exit(status); exit(status);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */ /* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
/* Updated: 2017/03/07 16:51:58 by wescande ### ########.fr */ /* Updated: 2017/03/08 13:04:29 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:07:10 by jhalford #+# #+# */ /* Created: 2016/12/13 17:07:10 by jhalford #+# #+# */
/* Updated: 2017/03/08 12:42:32 by jhalford ### ########.fr */ /* Updated: 2017/03/08 12:54:54 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */ /* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
/* Updated: 2017/02/14 14:08:21 by gwojda ### ########.fr */ /* Updated: 2017/03/08 12:56:46 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/07 11:20:27 by gwojda ### ########.fr */ /* Updated: 2017/03/08 13:00:08 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/07 16:38:43 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:05:23 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,6 +21,7 @@ int data_init(void)
data = data_singleton(); data = data_singleton();
data->env = ft_sstrdup(environ); data->env = ft_sstrdup(environ);
set_exitstatus(0, 1);
data->comp = NULL; data->comp = NULL;
data->opts = 0; data->opts = 0;
data->exec.fd_save[0] = fcntl(0, F_DUPFD_CLOEXEC); data->exec.fd_save[0] = fcntl(0, F_DUPFD_CLOEXEC);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/08 12:41:03 by jhalford ### ########.fr */ /* Updated: 2017/03/08 12:59:55 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -124,6 +124,6 @@ int main(int ac, char **av)
// parser_clean; // parser_clean;
; ;
} }
shell_exit(); builtin_exit(NULL, NULL, NULL);
return (0); return (0);
} }

View file

@ -1,26 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* shell_exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */
/* Updated: 2017/02/21 20:14:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void shell_exit(void)
{
t_data *data;
/* DG("shell_exit()"); */
data = data_singleton();
data_exit();
if (SH_HAS_JOBC(data->opts))
job_kill_all();
if (SH_IS_INTERACTIVE(data->opts))
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/07 16:38:13 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:04:03 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,6 @@ void shell_init(int ac, char **av)
data = data_singleton(); data = data_singleton();
data->argc = ac; data->argc = ac;
data->argv = ft_sstrdup(av); data->argv = ft_sstrdup(av);
/* atexit(&shell_exit); */
shell_get_opts(ac, av); shell_get_opts(ac, av);
if (SH_IS_INTERACTIVE(data->opts)) if (SH_IS_INTERACTIVE(data->opts))
{ {