close #173
This commit is contained in:
commit
a91816741f
20 changed files with 90 additions and 106 deletions
|
|
@ -36,6 +36,7 @@ builtin/builtin_echo.c\
|
||||||
builtin/builtin_env.c\
|
builtin/builtin_env.c\
|
||||||
builtin/builtin_exit.c\
|
builtin/builtin_exit.c\
|
||||||
builtin/builtin_export.c\
|
builtin/builtin_export.c\
|
||||||
|
builtin/builtin_func.c\
|
||||||
builtin/builtin_hash.c\
|
builtin/builtin_hash.c\
|
||||||
builtin/builtin_history.c\
|
builtin/builtin_history.c\
|
||||||
builtin/builtin_math.c\
|
builtin/builtin_math.c\
|
||||||
|
|
|
||||||
|
|
@ -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/22 17:28:02 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 15:13:06 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -49,6 +49,7 @@ int builtin_bg(const char *path, char *const av[], char *const envp[]);
|
||||||
int builtin_history(const char *path, char *const av[], char *const envp[]);
|
int builtin_history(const char *path, char *const av[], char *const envp[]);
|
||||||
int builtin_hash(const char *path, char *const av[], char *const envp[]);
|
int builtin_hash(const char *path, char *const av[], char *const envp[]);
|
||||||
int builtin_math(const char *path, char *const av[], char *const envp[]);
|
int builtin_math(const char *path, char *const av[], char *const envp[]);
|
||||||
|
int builtin_func(const char *path, char *const av[], char *const envp[]);
|
||||||
|
|
||||||
int bt_env_geti(char ***av, t_env_data *data);
|
int bt_env_geti(char ***av, t_env_data *data);
|
||||||
int error_msg(char *msg);
|
int error_msg(char *msg);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/23 16:13:56 by gwojda ### ########.fr */
|
/* Updated: 2017/03/24 16:17:40 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ void process_format(t_list **p, int firstp, int opts);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pprint(t_process *p);
|
void pprint(t_process *p);
|
||||||
int pprint_subshell(t_process *p);;
|
int pprint_subshell(t_process *p);
|
||||||
int pprint_brace(t_process *p);
|
int pprint_brace(t_process *p);
|
||||||
int pprint_while(t_process *p);
|
int pprint_while(t_process *p);
|
||||||
int pprint_if(t_process *p);
|
int pprint_if(t_process *p);
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* types.h :+: :+: :+: */
|
/* types.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/24 16:50:51 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 17:10:56 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -48,14 +48,13 @@ typedef struct s_data_template t_btexport;
|
||||||
typedef enum e_lexstate t_lexstate;
|
typedef enum e_lexstate t_lexstate;
|
||||||
typedef struct s_token t_token;
|
typedef struct s_token t_token;
|
||||||
typedef struct s_rvwords t_rvwords;
|
typedef struct s_rvwords t_rvwords;
|
||||||
|
|
||||||
typedef struct s_ld t_ld;
|
typedef struct s_ld t_ld;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Execution types
|
** Execution types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef int t_condition;
|
typedef int t_condition;
|
||||||
typedef struct s_job t_job;
|
typedef struct s_job t_job;
|
||||||
typedef struct s_process t_process;
|
typedef struct s_process t_process;
|
||||||
typedef int (t_execf)(const char *path,
|
typedef int (t_execf)(const char *path,
|
||||||
|
|
@ -64,11 +63,9 @@ typedef int (t_execf)(const char *path,
|
||||||
typedef enum e_process_type t_process_type;
|
typedef enum e_process_type t_process_type;
|
||||||
typedef enum e_process_state t_process_state;
|
typedef enum e_process_state t_process_state;
|
||||||
typedef union u_process_data t_process_data;
|
typedef union u_process_data t_process_data;
|
||||||
typedef struct s_process_map t_process_map;
|
typedef struct s_process_map t_process_map;
|
||||||
typedef struct s_data_cond t_data_while;
|
typedef struct s_data_cond t_data_while;
|
||||||
typedef struct s_data_cond t_data_if;
|
typedef struct s_data_cond t_data_if;
|
||||||
typedef struct s_data_cond t_data_if;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Parser types
|
** Parser types
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* btree_map.c :+: :+: :+: */
|
/* btree_map.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */
|
/* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 15:42:18 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 15:49:42 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* error.c :+: :+: :+: */
|
/* error.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */
|
/* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/24 15:10:44 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 16:22:55 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -39,6 +39,7 @@ int error_set(int n, ...)
|
||||||
|
|
||||||
int ft_perror(char *utility)
|
int ft_perror(char *utility)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}%s: %s{eoc}\n", utility ? utility : g_argv[0], g_errmsg);
|
ft_dprintf(2, "{red}%s: %s{eoc}\n", utility ? utility : g_argv[0],
|
||||||
|
g_errmsg);
|
||||||
return (g_errnum);
|
return (g_errnum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
63
42sh/log
63
42sh/log
|
|
@ -1,63 +0,0 @@
|
||||||
env lvl 2
|
|
||||||
env lvl 3
|
|
||||||
env lvl 4
|
|
||||||
env lvl 5
|
|
||||||
env lvl 6
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 6
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 5
|
|
||||||
env lvl 6
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 11
|
|
||||||
env lvl 4
|
|
||||||
env lvl 5
|
|
||||||
env lvl 6
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 11
|
|
||||||
env lvl 6
|
|
||||||
env lvl 7
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 11
|
|
||||||
env lvl 8
|
|
||||||
env lvl 9
|
|
||||||
env lvl 10
|
|
||||||
env lvl 11
|
|
||||||
env lvl 10
|
|
||||||
env lvl 11
|
|
||||||
env lvl 12
|
|
||||||
43
42sh/src/builtin/builtin_func.c
Normal file
43
42sh/src/builtin/builtin_func.c
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* builtin_func.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/24 15:03:02 by wescande #+# #+# */
|
||||||
|
/* Updated: 2017/03/24 17:01:44 by wescande ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
#define FUNC_USAGE "func"
|
||||||
|
|
||||||
|
int builtin_func(const char *path,
|
||||||
|
char *const argv[], char *const envp[])
|
||||||
|
{
|
||||||
|
t_list *list;
|
||||||
|
char **name;
|
||||||
|
t_btree **ast;
|
||||||
|
|
||||||
|
(void)envp;
|
||||||
|
(void)path;
|
||||||
|
if (!argv || !argv[0] || argv[1])
|
||||||
|
return (SH_ERR("usage: %s", FUNC_USAGE) ? 1 : 1);
|
||||||
|
list = data_singleton()->lst_func;
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
if (!(ast = list->content))
|
||||||
|
return (SH_ERR("unexpected error"));
|
||||||
|
name = token_to_argv(((t_astnode *)(*ast)->item)->data.cmd.token, 1);
|
||||||
|
if (name && name[0])
|
||||||
|
{
|
||||||
|
DG();
|
||||||
|
ft_putendl(name[0]);
|
||||||
|
}
|
||||||
|
ft_tabdel(&name);
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
@ -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/24 15:10:57 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 16:23:51 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ int bt_read_init(t_read *data, char **av)
|
||||||
if (isatty(STDIN))
|
if (isatty(STDIN))
|
||||||
data->opts |= BT_READ_INTER;
|
data->opts |= BT_READ_INTER;
|
||||||
if (bt_read_terminit(data) < 0)
|
if (bt_read_terminit(data) < 0)
|
||||||
exit (1);
|
exit(1);
|
||||||
if ((cliopts_get(av, g_read_opts, data)))
|
if ((cliopts_get(av, g_read_opts, data)))
|
||||||
return (ft_perror("read"));
|
return (ft_perror("read"));
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
|
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 16:24:41 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 15:12:42 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,6 +30,7 @@ t_stof g_builtin[] =
|
||||||
{"hash", &builtin_hash},
|
{"hash", &builtin_hash},
|
||||||
{"history", &builtin_history},
|
{"history", &builtin_history},
|
||||||
{"math", &builtin_math},
|
{"math", &builtin_math},
|
||||||
|
{"func", &builtin_func},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/24 15:12:22 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 15:39:48 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */
|
/* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 20:51:54 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 15:40:55 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,11 +20,16 @@ void job_hup_all(void)
|
||||||
|
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
jlist = jobc->first_job;
|
jlist = jobc->first_job;
|
||||||
|
if (!SH_HAS_JOBC(data_singleton()->opts))
|
||||||
|
return ;
|
||||||
while (jlist)
|
while (jlist)
|
||||||
{
|
{
|
||||||
job = jlist->content;
|
job = jlist->content;
|
||||||
|
DG("gonna SIGHUP %i", job->pgid);
|
||||||
|
builtin_jobs(NULL, NULL, NULL);
|
||||||
if (job->pgid != 1)
|
if (job->pgid != 1)
|
||||||
kill(-job->pgid, SIGHUP);
|
kill(-job->pgid, SIGHUP);
|
||||||
|
DG("after SIGHUP %i", job->pgid);
|
||||||
jlist = jlist->next;
|
jlist = jlist->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */
|
/* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/23 15:17:27 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 17:02:40 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -25,10 +25,8 @@ int lexer_bquote(t_list **alst, t_lexer *lexer)
|
||||||
if (get_lexer_stack(*lexer) != BQUOTE)
|
if (get_lexer_stack(*lexer) != BQUOTE)
|
||||||
push(&lexer->stack, lexer->state);
|
push(&lexer->stack, lexer->state);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
lexer->state = pop(&lexer->stack) &&
|
lexer->state = pop(&lexer->stack) &&
|
||||||
get_lexer_stack(*lexer) == DQUOTE ? DQUOTE : DEFAULT;
|
get_lexer_stack(*lexer) == DQUOTE ? DQUOTE : DEFAULT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '\\' && (back = 1))
|
else if (lexer->str[lexer->pos] == '\\' && (back = 1))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* lexer_dquote.c :+: :+: :+: */
|
/* lexer_dquote.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */
|
/* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/22 23:56:49 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 16:08:35 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -27,9 +27,9 @@ int lexer_dquote(t_list **alst, t_lexer *lexer)
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '\\')
|
else if (lexer->str[lexer->pos] == '\\')
|
||||||
{
|
{
|
||||||
if (lexer->str[lexer->pos + 1] == 0)
|
lexer->pos++;
|
||||||
return (lexer_backslash(alst, lexer));
|
if (lexer->str[lexer->pos] == 0)
|
||||||
token_append(token, lexer, 1, 1);
|
return (push(&lexer->stack, BACKSLASH) ? 0 : 0);
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE))
|
else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE))
|
||||||
return (lexer_lex(alst, lexer));
|
return (lexer_lex(alst, lexer));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
|
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/24 12:40:41 by wescande ### ########.fr */
|
/* Updated: 2017/03/24 15:55:08 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,14 +17,16 @@ void data_exit(void)
|
||||||
t_data *data;
|
t_data *data;
|
||||||
|
|
||||||
data = data_singleton();
|
data = data_singleton();
|
||||||
|
ft_strdel(&data->binary);
|
||||||
ft_sstrfree(data->env);
|
ft_sstrfree(data->env);
|
||||||
ft_sstrfree(data->local_var);
|
ft_sstrfree(data->local_var);
|
||||||
ft_sstrfree(data->argv);
|
ft_sstrfree(data->argv);
|
||||||
lexer_destroy(&data->lexer);
|
lexer_destroy(&data->lexer);
|
||||||
parser_destroy(&data->parser);
|
parser_destroy(&data->parser);
|
||||||
ft_lstdel(&data->jobc.first_job, &job_free);
|
ft_lstdel(&data->jobc.first_job, &job_free);
|
||||||
|
ft_lstdel(&data->lst_func, &tree_func_free);
|
||||||
ft_save_termios(-1);
|
ft_save_termios(-1);
|
||||||
ft_free_hash_table();
|
ft_free_hash_table();
|
||||||
free_history_list(data_singleton()->line.list_beg);
|
free_history_list(data->line.list_beg);
|
||||||
free(data_singleton());
|
free(data_singleton());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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/24 13:51:24 by wescande ### ########.fr */
|
/* Updated: 2017/03/24 16:27:51 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -92,12 +92,12 @@ int data_init(int ac, char **av)
|
||||||
term_name = "dumb";
|
term_name = "dumb";
|
||||||
if (tgetent(NULL, term_name) != 1)
|
if (tgetent(NULL, term_name) != 1)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}TERM name is not a tty\n{eoc}");
|
SH_ERR("TERM name is not a tty");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (path_binary_save(av[0]))
|
if (path_binary_save(av[0]))
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}Failed to resolve binary name\n{eoc}");
|
SH_ERR("Failed to resolve binary name");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* tree_type.c :+: :+: :+: */
|
/* ft_putast.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/14 22:11:26 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 16:28:14 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ char *ft_putast(void *nodein)
|
||||||
{
|
{
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
node = nodein;
|
node = nodein;
|
||||||
|
|
||||||
if (node->type == TK_BANG)
|
if (node->type == TK_BANG)
|
||||||
return ("TK_BANG");
|
return ("TK_BANG");
|
||||||
if (node->type == TK_DSEMI)
|
if (node->type == TK_DSEMI)
|
||||||
|
|
|
||||||
|
|
@ -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/24 15:18:55 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 15:30:51 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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/24 15:12:31 by jhalford ### ########.fr */
|
/* Updated: 2017/03/24 17:05:29 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,10 +29,9 @@ int get_c_arg(char ***av, t_data *data)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_input_fd(t_data *data)
|
static int get_input_fd(t_data *data, char *file)
|
||||||
{
|
{
|
||||||
static int fds[2] = {-1, STDIN};
|
static int fds[2] = {-1, STDIN};
|
||||||
char *file;
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (data->opts & SH_OPTS_LC && (file = data->c_arg))
|
if (data->opts & SH_OPTS_LC && (file = data->c_arg))
|
||||||
|
|
@ -94,7 +93,7 @@ int shell_init(int ac, char **av)
|
||||||
}
|
}
|
||||||
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);
|
||||||
if ((data->fd = get_input_fd(data)) < 0)
|
if ((data->fd = get_input_fd(data, NULL)) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0)
|
if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
5
|
|
||||||
Loading…
Reference in a new issue