This commit is contained in:
gwojda 2017-03-22 21:00:00 +01:00
commit 974a896083
43 changed files with 149 additions and 202 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */ /* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
/* Updated: 2017/03/20 23:22:19 by ariard ### ########.fr */ /* Updated: 2017/03/22 17:28:02 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,7 +22,7 @@
# define BT_ENV_LI (1 << 0) # define BT_ENV_LI (1 << 0)
# define BT_ENV_LU (1 << 1) # define BT_ENV_LU (1 << 1)
struct s_env_data struct s_env_data
{ {
t_flag flag; t_flag flag;
char **av_data; char **av_data;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:02:39 by jhalford #+# #+# */ /* Created: 2017/01/20 15:02:39 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:25:08 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:36:44 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/18 11:13:04 by alao #+# #+# */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */
/* Updated: 2017/03/17 17:23:34 by gwojda ### ########.fr */ /* Updated: 2017/03/22 18:19:43 by alao ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -185,5 +185,6 @@ char *path_solver(t_comp *c, char *cmd, char *cwd);
int c_exclusion_folder(t_comp *c); int c_exclusion_folder(t_comp *c);
int ft_sstrlen(char **s); int ft_sstrlen(char **s);
char *ft_sstrtostr(char **s, char *sep); char *ft_sstrtostr(char **s, char *sep);
char *ft_add_escape(char *str, char to_escape);
#endif #endif

View file

@ -1,83 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_input.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/09 02:05:22 by sbenning #+# #+# */
/* Updated: 2017/03/16 15:58:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_INPUT_H
# define FT_INPUT_H
/*
* Input code mapping (!!!!LINUX!!!!)
* TODO Same for MACOSX
*/
# ifdef __linux__
# define RL_INSERT_CODE 0x7e325b1b
# define RL_CLEAR_CODE 0xc
# define RL_NL_CODE 0xa
# define RL_COMP_CODE 0x9
# define RL_LEFT_CODE 0x445b1b
# define RL_RIGHT_CODE 0x435b1b
# define RL_WLEFT_CODE 0x44323b315b1b
# define RL_WRIGHT_CODE 0x43323b315b1b
# define RL_HOME_CODE 0x485b1b
# define RL_END_CODE 0x465b1b
# define RL_PAGEUP_CODE 0x7e355b1b
# define RL_PAGEDOWN_CODE 0x7e365b1b
# define RL_SELECT_RIGHT_CODE 0x43333b315b1b
# define RL_SELECT_LEFT_CODE 0x44333b315b1b
# define RL_SELECT_PAGEUP_CODE 0x7e333b355b1b
# define RL_SELECT_PAGEDOWN_CODE 0x7e333b365b1b
# define RL_SELECT_HOME_CODE 0x48333b315b1b
# define RL_SELECT_END_CODE 0x46333b315b1b
# define RL_SELECT_WRIGHT_CODE 0x43343b315b1b
# define RL_SELECT_WLEFT_CODE 0x44343b315b1b
# define RL_RETARR_CODE 0x7f
# define RL_SUPPR_CODE 0x7e335b1b
# define RL_ESC_CODE 0x5c
# define RL_QUOTE_CODE 0x27
# define RL_DQUOTE_CODE 0x22
# define RL_COPY_CODE 0x631b
# define RL_CUT_CODE 0x781b
# define RL_PASTE_CODE 0x761b
# endif
# ifdef __APPLE__
# define RL_INSERT_CODE 0x53323b315b1b
# define RL_CLEAR_CODE 0xc
# define RL_NL_CODE 0xa
# define RL_COMP_CODE 0x9
# define RL_LEFT_CODE 0x445b1b
# define RL_RIGHT_CODE 0x435b1b
# define RL_WLEFT_CODE 0x44323b315b1b
# define RL_WRIGHT_CODE 0x43323b315b1b
# define RL_HOME_CODE 0x485b1b
# define RL_END_CODE 0x465b1b
# define RL_PAGEUP_CODE 0x7e355b1b
# define RL_PAGEDOWN_CODE 0x7e365b1b
# define RL_SELECT_RIGHT_CODE 0x435b1b1b
# define RL_SELECT_LEFT_CODE 0x445b1b1b
# define RL_SELECT_PAGEUP_CODE 0x7e355b1b1b
# define RL_SELECT_PAGEDOWN_CODE 0x7e365b1b1b
# define RL_SELECT_HOME_CODE 0X48393b315b1b
# define RL_SELECT_END_CODE 0X46393b315b1b
# define RL_SELECT_WRIGHT_CODE 0x4330313b315b1b
# define RL_SELECT_WLEFT_CODE 0x4430313b315b1b
# define RL_RETARR_CODE 0x7f
# define RL_SUPPR_CODE 0x7e335b1b
# define RL_ESC_CODE 0x5c
# define RL_QUOTE_CODE 0x27
# define RL_DQUOTE_CODE 0x22
# define RL_COPY_CODE 0xa7c3
# define RL_CUT_CODE 0x8889e2
# define RL_PASTE_CODE 0x9a88e2
# endif
#endif

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/22 20:57:29 by gwojda ### ########.fr */ /* Updated: 2017/03/22 20:59:35 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,8 +30,6 @@
# include <dirent.h> # include <dirent.h>
# include <locale.h> # include <locale.h>
# include "ft_input.h"
# define FLECHE_HAUT 4283163 # define FLECHE_HAUT 4283163
# define FLECHE_BAS 4348699 # define FLECHE_BAS 4348699
# define FLECHE_GAUCHE 4479771 # define FLECHE_GAUCHE 4479771

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:25:09 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:13:32 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,12 +6,13 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:23:54 by jhalford ### ########.fr */ /* Updated: 2017/03/22 17:29:53 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef MINISHELL_H #ifndef MINISHELL_H
# define MINISHELL_H # define MINISHELL_H
# define SHELL_NAME "minishell" # define SHELL_NAME "minishell"
# include <dirent.h> # include <dirent.h>

View file

@ -1,11 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */
/* parser.h :+: :+: :+: */ /* parser.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */ /* Created: 2017/03/22 17:22:51 by ariard #+# #+# */
/* Updated: 2017/03/03 18:18:14 by ariard ### ########.fr */ /* Updated: 2017/03/22 17:25:11 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -35,10 +36,10 @@ struct s_parser
struct s_aggrematch struct s_aggrematch
{ {
t_sym top; t_sym top;
t_sym under; t_sym under;
t_sym new_sym; t_sym new_sym;
int erase_sym; int erase_sym;
}; };
struct s_prodmatch struct s_prodmatch
@ -82,15 +83,10 @@ int error_eof(void);
int ft_read_stack(t_sym *stack); int ft_read_stack(t_sym *stack);
char *read_state(t_sym current); char *read_state(t_sym current);
/*
* Build AST - rewriting
*
*/
struct s_treematch struct s_treematch
{ {
t_type type; t_type type;
int (*add)(t_btree **ast, t_list **lst); int (*add)(t_btree **ast, t_list **lst);
}; };
int build_tree(t_btree **ast, t_list **lst); int build_tree(t_btree **ast, t_list **lst);
@ -145,7 +141,7 @@ int superflous_token(t_btree **ast, t_list **list);
void sym_free(void *data, size_t size); void sym_free(void *data, size_t size);
void tree_func_free(void *data, size_t content_size); void tree_func_free(void *data, size_t content_size);
struct s_distrostree struct s_distrostree
{ {
int (*test)(t_btree **ast, t_list **lst); int (*test)(t_btree **ast, t_list **lst);
int (*add)(t_btree **ast, t_list **lst); int (*add)(t_btree **ast, t_list **lst);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:22:52 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:36:55 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */ /* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:48:34 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:21:35 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:50:14 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:21:49 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -54,7 +54,7 @@ int bt_read_loop(t_read *data)
esc = 0; esc = 0;
i = 0; i = 0;
if (data->prompt && data->opts & BT_READ_INTER) if (data->prompt && (data->opts & BT_READ_INTER))
ft_printf(data->prompt); ft_printf(data->prompt);
while (42) while (42)
{ {

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */ /* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
/* Updated: 2017/03/22 15:14:41 by gwojda ### ########.fr */ /* Updated: 2017/03/22 20:25:19 by alao ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,7 +30,7 @@ void c_seek_abs_path(t_comp *c, char *current_word)
if (current_word[0] == '~') if (current_word[0] == '~')
{ {
tmp = c->cpath; tmp = c->cpath;
c->cpath = ft_str3join(getenv("PWD"), "/", c->cpath + 2); c->cpath = ft_str3join(getenv("HOME"), "/", c->cpath + 2);
free(tmp); free(tmp);
} }
!c->match ? c->match = ft_strdupi_w(ft_strrchr(c->rcmd, '/') + 1) : 0; !c->match ? c->match = ft_strdupi_w(ft_strrchr(c->rcmd, '/') + 1) : 0;

View file

@ -6,12 +6,61 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/16 22:17:10 by alao #+# #+# */ /* Created: 2017/02/16 22:17:10 by alao #+# #+# */
/* Updated: 2017/03/17 16:51:53 by gwojda ### ########.fr */ /* Updated: 2017/03/22 18:23:04 by alao ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "completion.h" #include "completion.h"
/*
** Count the number of time char c is in str.
*/
static size_t ft_strxchr(char *str, char c)
{
size_t rt;
rt = 0;
while(*str)
{
if (*str == c)
rt++;
str++;
}
return (rt);
}
/*
** Add escape char \ for char to_escape.
*/
char *ft_add_escape(char *str, char to_escape)
{
char *rt;
int i;
int j;
if (!str)
return (NULL);
if (!ft_strxchr(str, ' '))
return (ft_strdup(str));
rt = ft_strnew(ft_strlen(str) + ft_strxchr(str, to_escape));
i = 0;
j = 0;
while (str[i])
{
if (str[i] == to_escape)
{
i++;
rt[j++] = '\\';
rt[j++] = ' ';
}
else
rt[j++] = str[i++];
}
return (rt);
}
/* /*
** Support: Return the size of a char**. ** Support: Return the size of a char**.
*/ */

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */ /* Created: 2017/02/03 13:10:38 by alao #+# #+# */
/* Updated: 2017/03/21 14:37:14 by gwojda ### ########.fr */ /* Updated: 2017/03/22 18:20:29 by alao ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -53,19 +53,22 @@ int c_updater(t_comp *c, char *select)
{ {
char *tmp; char *tmp;
char *rt; char *rt;
char *alter;
tmp = NULL; tmp = NULL;
rt = NULL; rt = NULL;
alter = ft_add_escape(select, ' ');
if (c->match) if (c->match)
tmp = ft_strsub(c->rcmd, 0, ft_strlen(c->rcmd) - ft_strlen(c->match)); tmp = ft_strsub(c->rcmd, 0, ft_strlen(c->rcmd) - ft_strlen(c->match));
else else
tmp = ft_strdup(c->rcmd); tmp = ft_strdup(c->rcmd);
rt = ft_strjoin(tmp, select); rt = ft_strjoin(tmp, alter);
tmp ? ft_memdel((void *)&tmp) : (0); tmp ? ft_memdel((void *)&tmp) : (0);
c->rcmd ? ft_memdel((void *)&c->rcmd) : (0); c->rcmd ? ft_memdel((void *)&c->rcmd) : (0);
c->rcmd = ft_strdup(rt); c->rcmd = ft_strdup(rt);
c_updater_rcmd(c); c_updater_rcmd(c);
rt ? ft_memdel((void *)&rt) : (0); rt ? ft_memdel((void *)&rt) : (0);
alter ? ft_memdel((void *)&alter) : (0);
c_clear(data_singleton()); c_clear(data_singleton());
return (1); return (1);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/21 20:15:59 by ariard ### ########.fr */ /* Updated: 2017/03/22 18:27:03 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ /* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:09:10 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:26:03 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/21 20:18:34 by ariard #+# #+# */ /* Created: 2017/03/21 20:18:34 by ariard #+# #+# */
/* Updated: 2017/03/21 20:53:45 by ariard ### ########.fr */ /* Updated: 2017/03/22 19:25:38 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,6 @@
int pfree_func(t_process *p) int pfree_func(t_process *p)
{ {
ft_putstr("hello");
btree_del(&p->data.function.content, &ast_free); btree_del(&p->data.function.content, &ast_free);
return (0); return (0);
} }

View file

@ -6,13 +6,13 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */ /* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
/* Updated: 2017/03/22 16:22:34 by gwojda ### ########.fr */ /* Updated: 2017/03/22 19:37:08 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define FUNCERR_0 SHELL_NAME ":maximum nested function level reached\n" #define FUNCERR_0 SHELL_NAME ":maximum nested function level reached"
int plaunch_function(t_process *p) int plaunch_function(t_process *p)
{ {
@ -36,6 +36,6 @@ int plaunch_function(t_process *p)
builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL",
ft_itoa(value), 0}, NULL); ft_itoa(value), 0}, NULL);
ft_exec(&p->data.function.content); ft_exec(&p->data.function.content);
DG(); builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", "0", 0}, NULL);
return (ft_atoi(ft_getenv(data_singleton()->env, "?"))); return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:26:53 by wescande #+# #+# */ /* Created: 2017/03/07 17:26:53 by wescande #+# #+# */
/* Updated: 2017/03/21 18:10:08 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:23:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,6 +16,5 @@ int plaunch_if(t_process *p)
{ {
data_singleton()->exec.attrs &= ~EXEC_IF_BRANCH; data_singleton()->exec.attrs &= ~EXEC_IF_BRANCH;
ft_exec(&p->data.d_if.content); ft_exec(&p->data.d_if.content);
/* set_exitstatus(ft_atoi(ft_getenv(data_singleton()->env, "?"))); */
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 22:04:42 by wescande #+# #+# */ /* Created: 2017/03/07 22:04:42 by wescande #+# #+# */
/* Updated: 2017/03/21 00:51:39 by wescande ### ########.fr */ /* Updated: 2017/03/22 19:22:56 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:20:53 by wescande #+# #+# */ /* Created: 2017/03/07 17:20:53 by wescande #+# #+# */
/* Updated: 2017/03/21 00:48:16 by wescande ### ########.fr */ /* Updated: 2017/03/22 19:23:55 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:34:15 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:26:53 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,10 +17,7 @@ int process_fork(t_process *p)
pid_t pid; pid_t pid;
if ((pid = fork()) == -1) if ((pid = fork()) == -1)
{ exit(SH_ERR("fork(): %s", strerror(errno)));
ft_dprintf(3, "{red}%s: internal fork error{eoc}\n", SHELL_NAME);
exit(1);
}
else if (pid) else if (pid)
return (pid); return (pid);
if (!p) if (!p)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:24:18 by gwojda ### ########.fr */ /* Updated: 2017/03/22 18:26:37 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 12:39:07 by jhalford #+# #+# */ /* Created: 2017/03/20 12:39:07 by jhalford #+# #+# */
/* Updated: 2017/03/20 16:26:47 by gwojda ### ########.fr */ /* Updated: 2017/03/22 18:24:31 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 17:47:53 by wescande #+# #+# */ /* Created: 2017/02/17 17:47:53 by wescande #+# #+# */
/* Updated: 2017/03/20 15:10:32 by wescande ### ########.fr */ /* Updated: 2017/03/22 19:24:52 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/31 22:18:46 by wescande #+# #+# */ /* Created: 2017/01/31 22:18:46 by wescande #+# #+# */
/* Updated: 2017/03/21 18:13:25 by gwojda ### ########.fr */ /* Updated: 2017/03/22 19:24:29 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -66,7 +66,7 @@ unsigned char **ft_strsplit_esc(const char *str,
if ((pos = -1) && !str) if ((pos = -1) && !str)
return (NULL); return (NULL);
if (!(s1 = (unsigned char **)ft_malloc(sizeof(*s1) * (nb_c(str, esc, c) + 1)))) if (!(s1 = ft_malloc(sizeof(*s1) * (nb_c(str, esc, c) + 1))))
return (NULL); return (NULL);
i = 0; i = 0;
fix = str; fix = str;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 16:54:18 by jhalford #+# #+# */ /* Created: 2017/01/09 16:54:18 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:49:06 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:29:32 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,7 +23,7 @@ int builtin_bg(const char *path, char *const av[], char *const envp[])
(void)envp; (void)envp;
if (!SH_HAS_JOBC(data_singleton()->opts)) if (!SH_HAS_JOBC(data_singleton()->opts))
{ {
ft_dprintf(2, "{red}bg: %s{eoc}\n", SH_MSG_NOJOBC); SH_ERR("bg: %s", SH_MSG_NOJOBC);
return (-1); return (-1);
} }
jobc = &data_singleton()->jobc; jobc = &data_singleton()->jobc;
@ -35,8 +35,8 @@ int builtin_bg(const char *path, char *const av[], char *const envp[])
return (0); return (0);
} }
else if (av[1]) else if (av[1])
ft_dprintf(2, "{red}bg: job not found: %i{eoc}\n", id); SH_ERR("bg: job not found: [%i]", id);
else else
ft_dprintf(2, "{red}bg: no current job{eoc}\n"); SH_ERR("bg: no current job");
return (1); return (1);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */ /* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:30:05 by gwojda ### ########.fr */ /* Updated: 2017/03/22 19:31:00 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,21 +28,15 @@ int builtin_fg(const char *path, char *const av[], char *const envp[])
} }
jobc = &data_singleton()->jobc; jobc = &data_singleton()->jobc;
job_getrank(&rank); job_getrank(&rank);
if (av[1] ? (id = *av[1]) : 0) id = av[1] ? ft_atoi(av[1]) : rank[0];
if ((jlist = ft_lst_find(jobc->first_job, &id, job_cmp_id)))
{ {
if ((jlist = ft_lst_find(jobc->first_job, &id, job_cmp_id))) job_run(jlist->content, 1);
job_run(jlist->content, 1); return (0);
else
SH_ERR("{red}fg: job not found: [%i]", id);
} }
else if (av[1])
SH_ERR("fg: job not found: [%i]", id);
else else
{ SH_ERR("fg: no current job");
if ((jlist = ft_lst_find(jobc->first_job, &rank[0], job_cmp_id)))
job_run(jlist->content, 1);
else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id)))
job_run(jlist->content, 1);
else
SH_ERR("fg: no current job");
}
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */ /* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
/* Updated: 2017/03/21 01:30:10 by wescande ### ########.fr */ /* Updated: 2017/03/22 19:36:16 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,8 +24,7 @@ int job_addprocess(t_process *p)
job_update_id(); job_update_id();
job->id = jobc->current_id; job->id = jobc->current_id;
job->pgid = SH_IS_INTERACTIVE(data_singleton()->opts) ? job->pgid = SH_IS_INTERACTIVE(data_singleton()->opts) ?
/* p->pid : data_singleton()->jobc.shell_pgid; */ p->pid : getpgid(0);
p->pid : getpgid(0);
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job))); ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
} }
job = jobc->first_job->content; job = jobc->first_job->content;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 16:54:18 by jhalford #+# #+# */ /* Created: 2017/01/09 16:54:18 by jhalford #+# #+# */
/* Updated: 2017/03/21 14:24:09 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:30:10 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */ /* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:31:28 by jhalford ### ########.fr */ /* Updated: 2017/03/22 17:48:54 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,9 +28,7 @@ int job_wait(int id)
{ {
if ((pid = waitpid(-j->pgid, &status, WUNTRACED)) == -1 if ((pid = waitpid(-j->pgid, &status, WUNTRACED)) == -1
&& errno != ECHILD) && errno != ECHILD)
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", SH_ERR("waitpid(): %s", strerror(errno));
SHELL_NAME, errno);
DG("wait trigger pid=%i", pid);
if (pid <= 1 || mark_process_status(pid, status) if (pid <= 1 || mark_process_status(pid, status)
|| job_is_stopped(j) || job_is_stopped(j)
|| job_is_completed(j)) || job_is_completed(j))

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/21 20:49:32 by ariard ### ########.fr */ /* Updated: 2017/03/22 18:15:48 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */ /* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */
/* Updated: 2017/01/22 20:56:45 by ariard ### ########.fr */ /* Updated: 2017/03/22 18:17:42 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,5 +15,6 @@
void sigint_handler(int signo) void sigint_handler(int signo)
{ {
(void)signo; (void)signo;
set_exitstatus(1, 1);
DG("pid:%i got SIGINT", getpid()); DG("pid:%i got SIGINT", getpid());
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 16:29:35 by jhalford #+# #+# */ /* Created: 2017/03/05 16:29:35 by jhalford #+# #+# */
/* Updated: 2017/03/05 16:29:36 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:15:28 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,12 +22,13 @@ int lexer_curly_braces(t_list **alst, t_lexer *lexer)
if (lexer->str[lexer->pos] == '{') if (lexer->str[lexer->pos] == '{')
{ {
token->type = TK_LBRACE; token->type = TK_LBRACE;
push(&lexer->stack, PAREN); push(&lexer->stack, CURLY_BRACKETS);
} }
else if (get_lexer_stack(*lexer)) else
{ {
token->type = TK_RBRACE; token->type = TK_RBRACE;
pop(&lexer->stack); if (get_lexer_stack(*lexer) == CURLY_BRACKETS)
pop(&lexer->stack);
} }
lexer->pos++; lexer->pos++;
lexer->state = DEFAULT; lexer->state = DEFAULT;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */ /* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:02:05 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:13:29 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */ /* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */
/* Updated: 2017/03/22 17:16:17 by jhalford ### ########.fr */ /* Updated: 2017/03/22 18:13:07 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/22 17:25:20 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:37:21 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,11 +43,10 @@ static int handle_instruction(t_list **token, t_btree **ast)
return (ret); return (ret);
if (do_lexer_routine(token, stream) > 0) if (do_lexer_routine(token, stream) > 0)
continue ; continue ;
/* token_print(*token); */
if ((ret = do_parser_routine(token, ast)) == 1 if ((ret = do_parser_routine(token, ast)) == 1
&& SH_NO_INTERACTIVE(data->opts)) && SH_NO_INTERACTIVE(data->opts))
return (ret); return (ret);
else if (ret == 2) else if (ret > 0)
break ; break ;
} }
if (data->parser.state == SUCCESS && ft_exec(ast) < 0) if (data->parser.state == SUCCESS && ft_exec(ast) < 0)

View file

@ -6,11 +6,12 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:08:21 by jhalford ### ########.fr */ /* Updated: 2017/03/22 19:36:07 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define SHELL_USAGE "42sh [-c command | [<]script] [--no-jobcontrol]"
static t_cliopts g_opts[] = static t_cliopts g_opts[] =
{ {
@ -42,16 +43,12 @@ static int get_input_fd(t_data *data)
} }
else if ((file = *data->av_data)) else if ((file = *data->av_data))
{ {
DG("file=%s", file);
if (stat(file, &buf) < 0) if (stat(file, &buf) < 0)
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SH_ERR("%s: No such file or directory", file);
data->argv[0], file);
else if (S_ISDIR(buf.st_mode)) else if (S_ISDIR(buf.st_mode))
ft_printf("{red}%s: %s: is a directory\n{eoc}", data->argv[0], SH_ERR("%s: is a directory", file);
file);
else if ((fds[PIPE_READ] = open(file, O_RDONLY | O_CLOEXEC)) < 0) else if ((fds[PIPE_READ] = open(file, O_RDONLY | O_CLOEXEC)) < 0)
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SH_ERR("%s: No such file or directory", file);
data->argv[0], file);
} }
else else
return (STDIN); return (STDIN);
@ -75,8 +72,7 @@ static int interactive_settings(void)
shell_resetsig(); shell_resetsig();
if (setpgid(*shell_pgid, *shell_pgid)) if (setpgid(*shell_pgid, *shell_pgid))
{ {
ft_dprintf(2, SH_ERR("setpgid(): %s", strerror(errno));
"{red}Couldnt put the shell in it's own process group{eoc}\n");
return (-1); return (-1);
} }
tcsetpgrp(STDIN, *shell_pgid); tcsetpgrp(STDIN, *shell_pgid);
@ -84,12 +80,6 @@ static int interactive_settings(void)
return (0); return (0);
} }
static int usage(void)
{
ft_dprintf(2, "usage: 42sh [-c command | [<]script] [--no-jobcontrol]\n");
return (0);
}
int shell_init(int ac, char **av) int shell_init(int ac, char **av)
{ {
t_data *data; t_data *data;
@ -99,8 +89,8 @@ int shell_init(int ac, char **av)
return (-1); return (-1);
if (cliopts_get(av, g_opts, data)) if (cliopts_get(av, g_opts, data))
{ {
usage(); ft_perror();
return (ft_perror()); return (SH_ERR("usage: %s", SHELL_USAGE));
} }
if (!isatty(STDIN) || *data->av_data) if (!isatty(STDIN) || *data->av_data)
data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC); data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 16:07:14 by jhalford #+# #+# */ /* Created: 2017/03/22 16:07:14 by jhalford #+# #+# */
/* Updated: 2017/03/22 16:25:14 by jhalford ### ########.fr */ /* Updated: 2017/03/22 17:49:38 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/24 23:43:07 by ariard #+# #+# */ /* Created: 2017/02/24 23:43:07 by ariard #+# #+# */
/* Updated: 2017/03/22 16:52:57 by gwojda ### ########.fr */ /* Updated: 2017/03/22 19:21:58 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -100,7 +100,7 @@ t_list *is_already_func(t_btree **new)
ret = (new_name && new_name[0] && old_name && old_name[0] ret = (new_name && new_name[0] && old_name && old_name[0]
&& !ft_strcmp(new_name[0], old_name[0])) ? 0 : 1; && !ft_strcmp(new_name[0], old_name[0])) ? 0 : 1;
ft_tabdel(&old_name); ft_tabdel(&old_name);
tmp = tmp->next; tmp = (ret) ? tmp->next : tmp;
} }
ft_tabdel(&new_name); ft_tabdel(&new_name);
if (!ret) if (!ret)
@ -116,8 +116,10 @@ int add_one_func(t_btree **ast, t_list **lst)
(void)lst; (void)lst;
func_ast = btree_map(*ast, &node_copy); func_ast = btree_map(*ast, &node_copy);
if ((old_func = is_already_func(&func_ast))) if ((old_func = is_already_func(&func_ast)))
{
ft_lst_delif(&data_singleton()->lst_func, ft_lst_delif(&data_singleton()->lst_func,
old_func->content, &ft_addrcmp, &tree_func_free); old_func->content, &ft_addrcmp, &tree_func_free);
}
ft_lsteadd(&data_singleton()->lst_func, ft_lstnew(&func_ast, sizeof(*ast))); ft_lsteadd(&data_singleton()->lst_func, ft_lstnew(&func_ast, sizeof(*ast)));
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/18 19:18:21 by ariard ### ########.fr */ /* Updated: 2017/03/22 19:00:06 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -38,6 +38,8 @@ t_aggrematch g_aggrematch[] =
{TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO}, {TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO},
{TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE}, {TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE},
{TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE}, {TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
{TK_PAREN_CLOSE, SUBSHELL, SUBSHELL, TK_PAREN_OPEN},
// {TK_PAREN_CLOSE, SEMI_SUBSHELL, SUBSHELL, TK_PAREN_OPEN},
{TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN},
{TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN},
{TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/22 16:11:11 by ariard ### ########.fr */ /* Updated: 2017/03/22 19:00:15 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -578,6 +578,7 @@ t_stackmatch g_stackmatch[] =
{TK_PAREN_CLOSE, COMPOUND_LIST}, {TK_PAREN_CLOSE, COMPOUND_LIST},
{TK_PAREN_CLOSE, FUNC_NAME}, {TK_PAREN_CLOSE, FUNC_NAME},
{TK_PAREN_CLOSE, OPEN_FUNC}, {TK_PAREN_CLOSE, OPEN_FUNC},
{TK_PAREN_CLOSE, SUBSHELL},
{TK_RBRACE, TK_SEMI}, {TK_RBRACE, TK_SEMI},
{TK_RBRACE, END_COMMAND}, {TK_RBRACE, END_COMMAND},
{TK_RBRACE, SEPARATOR_OP}, {TK_RBRACE, SEPARATOR_OP},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */ /* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
/* Updated: 2017/03/22 16:10:09 by ariard ### ########.fr */ /* Updated: 2017/03/22 19:26:03 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -68,14 +68,14 @@ t_prodmatch g_prodmatch[] =
{TK_ASSIGNMENT_WORD, TK_ELIF, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_ELIF, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, TK_ELSE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_ELSE, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, NEWLINE_LIST, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, NEWLINE_LIST, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, CMD_NAME, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CMD_NAME, CMD_SUFFIX},
{TK_ASSIGNMENT_WORD, CMD_SUPERIOR, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CMD_SUPERIOR, CMD_SUFFIX},
{TK_ASSIGNMENT_WORD, COMPOUND_LIST, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, COMPOUND_LIST, CMD_SUFFIX},
{TK_ASSIGNMENT_WORD, COMPLETE_CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, COMPLETE_CONDITION, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CONDITION, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, AND_OR, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, AND_OR, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, AND_OR_MAJOR, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, AND_OR_MAJOR, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_SUFFIX},
{TK_ASSIGNMENT_WORD, SEQUENCE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, SEQUENCE, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, COMPLETE_COMMANDS, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, COMPLETE_COMMANDS, CMD_PREFIX},
{TK_ASSIGNMENT_WORD, CMD_WORD, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, CMD_WORD, CMD_SUFFIX},