This commit is contained in:
Jack Halford 2017-03-27 18:07:20 +02:00
parent 2e49e0c302
commit a2545bb2e7
10 changed files with 33 additions and 31 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */
/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */
/* Updated: 2017/03/27 17:59:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,6 +39,5 @@ struct s_data_template
int cliopts_get(char **av, t_cliopts opt_map[], void *data);
t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg);
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg);
int cliopts_has(char **av, char c);
#endif

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 18:20:42 by ariard #+# #+# */
/* Updated: 2017/03/25 21:23:11 by ariard ### ########.fr */
/* Updated: 2017/03/27 18:00:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */
/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */
/* Updated: 2017/03/27 18:01:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
/* Updated: 2017/03/26 22:36:18 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:00:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,7 +23,6 @@ int redirect_dgreat(t_redir *redir)
return (ft_perror(NULL));
if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
exit(1);
fd_replace(fdold, fdnew);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
/* Updated: 2017/03/27 01:02:30 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:00:45 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
/* Updated: 2017/03/22 12:09:59 by gwojda ### ########.fr */
/* Updated: 2017/03/27 18:01:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,6 @@ static int check_validity(char *str, int i)
else if (!str[i + 1] || str[i + 1] == '"')
return (0);
return (1);
}
static int history_parsing_nb_and_name(char *str, int *i)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:04:32 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:02:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,6 @@ void data_exit(void)
t_data *data;
data = data_singleton();
/* ft_strdel(&data->line.input); */
ft_strdel(&data->binary);
ft_sstrfree(data->env);
ft_sstrfree(data->local_var);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:00:19 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:04:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,6 +66,15 @@ static int shlvl_inc(void)
return (0);
}
int modules_init(t_data *data)
{
lexer_init(&data->lexer);
parser_init(&data->parser);
exec_init(&data->exec);
jobc_init(&data->jobc);
return (0);
}
int data_init(int ac, char **av, char **env)
{
t_data *data;
@ -80,13 +89,10 @@ int data_init(int ac, char **av, char **env)
localenv_init();
if (shlvl_inc())
return (-1);
modules_init(data);
data->comp = NULL;
data->opts = SH_INTERACTIVE | SH_OPTS_JOBC;
data->lst_func = NULL;
lexer_init(&data->lexer);
parser_init(&data->parser);
exec_init(&data->exec);
jobc_init(&data->jobc);
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
term_name = "dumb";
if (tgetent(NULL, term_name) != 1)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/27 15:32:13 by jhalford #+# #+# */
/* Updated: 2017/03/27 15:57:21 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:02:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:06:12 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -89,10 +89,10 @@ int shell_init(int ac, char **av, char **env)
if (data_init(ac, av, env) < 0)
return (-1);
if (cliopts_get(av, g_opts, data))
return (ft_perror(NULL)
&& SH_ERR("%s", SHELL_USAGE1)
&& SH_ERR("%s", SHELL_USAGE2)
&& SH_ERR("%s", SHELL_USAGE3));
{
return (ft_perror(NULL) && SH_ERR("%s", SHELL_USAGE1)
&& SH_ERR("%s", SHELL_USAGE2) && SH_ERR("%s", SHELL_USAGE3));
}
if (!isatty(STDIN) || *data->av_data)
data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC);
if ((data->fd = get_input_fd(data, NULL)) < 0)