shell tokenize newline debut

This commit is contained in:
ariard@student.42.fr 2017-01-22 23:32:57 +01:00
parent f81a51cdd8
commit 830b04208e
17 changed files with 62 additions and 13 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
/* Updated: 2017/01/22 00:37:19 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:30:39 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
/* Updated: 2017/01/22 22:50:22 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:21:39 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -73,6 +73,8 @@ void data_exit(void);
int shell_single_command(char *command);
int shell_script(void);
void ft_expand_dollar(char **av, char **env);
char *ft_findexec(char *path, char *file);

View file

@ -6,7 +6,7 @@
/* By: ariard <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/21 22:50:22 by ariard #+# #+# */
/* Updated: 2017/01/22 22:19:32 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:02:55 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,4 +1,5 @@
#!/bin/yolosh
#!/bin/minishell
while [ 1 ]; do
sleep 1
echo "a"

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/11 16:11:11 by jhalford #+# #+# */
/* Updated: 2017/01/20 16:37:25 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:27:50 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
/* Updated: 2017/01/21 20:49:42 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:18:13 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
/* Updated: 2017/01/20 01:14:32 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:26:06 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/08 18:03:48 by sbenning #+# #+# */
/* Updated: 2017/01/22 21:43:48 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:15:27 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

Binary file not shown.

Binary file not shown.

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/01/22 22:52:41 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:09:43 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,6 +37,7 @@ int shell_single_command(char *command)
/* /1* btree_apply_infix(ast, &ft_putast2); *1/ */
if (ft_exec(&ast))
return (1);
return (0);
}
@ -51,7 +52,10 @@ int main(int ac, char **av)
}
if (ft_read_script(av[1]))
{
shell_single_command(data_singleton()->line.input);
if (data_singleton()->opts & SHELL_MODE_SCRIPT)
shell_script();
else
shell_single_command(data_singleton()->line.input);
return (0);
}
while (1)

View file

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* shell_script.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/22 23:06:34 by ariard #+# #+# */
/* Updated: 2017/01/22 23:32:27 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int shell_script()
{
t_list *token;
t_btree *ast;
t_list *tmp;
token = NULL;
ast = NULL;
tmp = data_singleton()->script.queue;
while (tmp)
{
if (ft_tokenize(&token, tmp->content , DEFAULT))
return (1);
tmp = tmp->next;
}
if (!token)
return (0);
// if (ft_post_tokenize(&token, command))
// return (1);
DG("after post_tokenize");
token_print(token);
if (ft_parse(&ast, &token))
return (1);
btree_print(STDBUG, ast, &ft_putast);
if (ft_exec(&ast))
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/21 22:49:31 by ariard #+# #+# */
/* Updated: 2017/01/22 22:19:42 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:11:59 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/22 21:42:27 by ariard #+# #+# */
/* Updated: 2017/01/22 22:53:34 by ariard ### ########.fr */
/* Updated: 2017/01/22 23:11:57 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -72,7 +72,7 @@ int rs_shebang_check(char *file, t_script *script)
else if (ft_strncmp(interpreter, "minishell", ft_strlen("minishell")) == 0)
{
data_singleton()->opts &= ~SHELL_MODE_MASK;
data_singleton()->opts |= SHELL_MODE_EXEC;
data_singleton()->opts |= SHELL_MODE_SCRIPT;
}
return (0);
}