builtin, lexer et parser .h a la nomre
This commit is contained in:
commit
be76e38a56
36 changed files with 141 additions and 129 deletions
|
|
@ -102,7 +102,6 @@ exec/plaunch_until.c\
|
||||||
exec/plaunch_while.c\
|
exec/plaunch_while.c\
|
||||||
exec/process_launch.c\
|
exec/process_launch.c\
|
||||||
exec/process_redirect.c\
|
exec/process_redirect.c\
|
||||||
exec/process_resetfds.c\
|
|
||||||
exec/process_set.c\
|
exec/process_set.c\
|
||||||
exec/process_setgroup.c\
|
exec/process_setgroup.c\
|
||||||
exec/process_setsig.c\
|
exec/process_setsig.c\
|
||||||
|
|
@ -274,6 +273,7 @@ main/data_singleton.c\
|
||||||
main/ft_putast.c\
|
main/ft_putast.c\
|
||||||
main/main.c\
|
main/main.c\
|
||||||
main/shell_init.c\
|
main/shell_init.c\
|
||||||
|
main/shell_reset.c\
|
||||||
parser/add_bang.c\
|
parser/add_bang.c\
|
||||||
parser/add_case.c\
|
parser/add_case.c\
|
||||||
parser/add_cmd.c\
|
parser/add_cmd.c\
|
||||||
|
|
|
||||||
|
|
@ -6,29 +6,30 @@
|
||||||
/* 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/20 15:34:47 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:25:08 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef BUILTIN_READ_H
|
#ifndef BUILTIN_READ_H
|
||||||
# define BUILTIN_READ_H
|
# define BUILTIN_READ_H
|
||||||
|
|
||||||
# define READ_OPT_LA (1 << 0)
|
# define BT_READ_LA (1 << 0)
|
||||||
# define READ_OPT_LD (1 << 1)
|
# define BT_READ_LD (1 << 1)
|
||||||
# define READ_OPT_LE (1 << 2)
|
# define BT_READ_LE (1 << 2)
|
||||||
# define READ_OPT_LI (1 << 3)
|
# define BT_READ_LI (1 << 3)
|
||||||
# define READ_OPT_LN (1 << 4)
|
# define BT_READ_LN (1 << 4)
|
||||||
# define READ_OPT_UN (1 << 5)
|
# define BT_READ_UN (1 << 5)
|
||||||
# define READ_OPT_LP (1 << 6)
|
# define BT_READ_LP (1 << 6)
|
||||||
# define READ_OPT_LR (1 << 7)
|
# define BT_READ_LR (1 << 7)
|
||||||
# define READ_OPT_LS (1 << 8)
|
# define BT_READ_LS (1 << 8)
|
||||||
# define READ_OPT_LT (1 << 9)
|
# define BT_READ_LT (1 << 9)
|
||||||
# define READ_OPT_LU (1 << 10)
|
# define BT_READ_LU (1 << 10)
|
||||||
|
# define BT_READ_INTER (1 << 11)
|
||||||
|
|
||||||
typedef struct s_read t_read;
|
typedef struct s_read t_read;
|
||||||
typedef struct s_readopt t_readopt;
|
typedef struct s_readopt t_readopt;
|
||||||
|
|
||||||
struct s_read
|
struct s_read
|
||||||
{
|
{
|
||||||
t_flag opts;
|
t_flag opts;
|
||||||
char **names;
|
char **names;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 20:17:27 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:35:00 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -144,7 +144,6 @@ int process_fork(t_process *p);
|
||||||
int process_setgroup(t_process *p, pid_t pid);
|
int process_setgroup(t_process *p, pid_t pid);
|
||||||
void process_setsig(void);
|
void process_setsig(void);
|
||||||
void process_reset(t_process *p);
|
void process_reset(t_process *p);
|
||||||
void process_resetfds(t_process *p);
|
|
||||||
|
|
||||||
int fd_is_valid(int fd, int flag);
|
int fd_is_valid(int fd, int flag);
|
||||||
int bad_fd(int fd);
|
int bad_fd(int fd);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 14:40:26 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:24:08 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
# define JOBS_OPT_L (1 << 0)
|
# define JOBS_OPT_L (1 << 0)
|
||||||
|
|
||||||
struct s_jobc
|
struct s_jobc
|
||||||
{
|
{
|
||||||
t_list *first_job;
|
t_list *first_job;
|
||||||
pid_t shell_pgid;
|
pid_t shell_pgid;
|
||||||
|
|
@ -75,9 +75,11 @@ void sigttou_handler(int signo);
|
||||||
|
|
||||||
int process_cmp_pid(t_process *p, pid_t *pid);
|
int process_cmp_pid(t_process *p, pid_t *pid);
|
||||||
void process_format(t_list **p, int firstp, int opts);
|
void process_format(t_list **p, int firstp, int opts);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Mapping pour afficher les process
|
** Mapping pour afficher les process
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -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:58 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:29:24 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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:26:34 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:29:53 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -32,17 +32,10 @@
|
||||||
# include "glob.h"
|
# include "glob.h"
|
||||||
# include "completion.h"
|
# include "completion.h"
|
||||||
# include "hash.h"
|
# include "hash.h"
|
||||||
/* # define malloc(x) NULL */
|
|
||||||
|
|
||||||
# define SH_MSG(s, ...) "{red}%s: " s "{eoc}\n", g_argv[0], ##__VA_ARGS__
|
# define SH_MSG(s, ...) "{red}%s: " s "{eoc}\n", g_argv[0], ##__VA_ARGS__
|
||||||
# define SH_ERR(s, ...) ft_dprintf(STDERR, SH_MSG(s, ##__VA_ARGS__))
|
# define SH_ERR(s, ...) ft_dprintf(STDERR, SH_MSG(s, ##__VA_ARGS__))
|
||||||
|
|
||||||
#ifndef DEBUG
|
|
||||||
# define DEBUG_MODE 0
|
|
||||||
#else
|
|
||||||
# define DEBUG_MODE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct s_data
|
struct s_data
|
||||||
{
|
{
|
||||||
t_flag opts;
|
t_flag opts;
|
||||||
|
|
@ -62,13 +55,15 @@ struct s_data
|
||||||
t_list *lst_func;
|
t_list *lst_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
t_data *data_singleton();
|
||||||
int shell_init(int ac, char **av);
|
int shell_init(int ac, char **av);
|
||||||
void shell_exit(void);
|
void shell_exit(void);
|
||||||
int data_init(int ac, char **av);
|
int data_init(int ac, char **av);
|
||||||
void data_exit(void);
|
void data_exit(void);
|
||||||
int get_c_arg(char ***av, t_data *data);
|
int get_c_arg(char ***av, t_data *data);
|
||||||
|
|
||||||
/* void content_free(void *data, size_t content_size); */
|
void shell_resetfds(void);
|
||||||
|
void shell_resetsig(void);
|
||||||
|
|
||||||
char *ft_putast(void *node);
|
char *ft_putast(void *node);
|
||||||
void ft_putast2(void *node);
|
void ft_putast2(void *node);
|
||||||
|
|
|
||||||
|
|
@ -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 16:53:22 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:30:06 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
# define SH_IS_INTERACTIVE(b) (b & SH_INTERACTIVE)
|
# define SH_IS_INTERACTIVE(b) (b & SH_INTERACTIVE)
|
||||||
# define SH_NO_INTERACTIVE(b) !(b & SH_INTERACTIVE)
|
# define SH_NO_INTERACTIVE(b) !(b & SH_INTERACTIVE)
|
||||||
|
|
||||||
# define SH_MSG_NOJOBC "no job-control"
|
# define SH_MSG_NOJOBC "no job-control"
|
||||||
|
|
||||||
typedef long long t_type;
|
typedef long long t_type;
|
||||||
typedef long long t_flag;
|
typedef long long t_flag;
|
||||||
|
|
@ -88,8 +88,6 @@ typedef struct s_errormatch t_errormatch;
|
||||||
typedef struct s_treematch t_treematch;
|
typedef struct s_treematch t_treematch;
|
||||||
typedef struct s_distrostree t_distrostree;
|
typedef struct s_distrostree t_distrostree;
|
||||||
|
|
||||||
t_data *data_singleton();
|
|
||||||
|
|
||||||
enum e_sym
|
enum e_sym
|
||||||
{
|
{
|
||||||
LINEBREAK = 1,
|
LINEBREAK = 1,
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_vprintf.c :+: :+: :+: */
|
/* ft_vprintf.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */
|
/* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 16:34:06 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:22:30 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ int ft_vasprintf(char **ret, const char *format, va_list ap)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
else if (!(final = ft_strjoin(final, (char[]){*str++, 0})))
|
else if (!(final = ft_strjoin(final, (char[]){*str++, 0})))
|
||||||
return (-1);
|
return (-1);
|
||||||
ft_strdel(&tmp);
|
ft_strdel(&tmp);
|
||||||
}
|
}
|
||||||
*ret = final;
|
*ret = final;
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* fd_replace.c :+: :+: :+: */
|
/* fd_replace.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/21 16:32:26 by jhalford #+# #+# */
|
/* Created: 2017/03/21 16:32:26 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 16:42:19 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:22:55 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,6 +15,6 @@
|
||||||
int fd_replace(int fd1, int fd2)
|
int fd_replace(int fd1, int fd2)
|
||||||
{
|
{
|
||||||
if (fd1 != fd2)
|
if (fd1 != fd2)
|
||||||
return(dup2_close(fd1, fd2));
|
return (dup2_close(fd1, fd2));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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/20 14:23:46 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:48:34 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -25,17 +25,23 @@ int bt_read_terminit(t_read *data)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
|
|
||||||
(void)data;
|
|
||||||
term = bt_read_term(1);
|
term = bt_read_term(1);
|
||||||
|
if (!(data->opts & BT_READ_INTER))
|
||||||
|
return (0);
|
||||||
term.c_lflag = ECHO | ECHOE | ECHOK | ICANON;
|
term.c_lflag = ECHO | ECHOE | ECHOK | ICANON;
|
||||||
term.c_lflag &= data->timeout ? ~ICANON : ~0;
|
{
|
||||||
if (data->opts & READ_OPT_LS)
|
term.c_lflag &= data->timeout ? ~ICANON : ~0;
|
||||||
|
term.c_cc[VTIME] = data->timeout * 10;
|
||||||
|
term.c_cc[VMIN] = !data->timeout;
|
||||||
|
}
|
||||||
|
if (data->opts & BT_READ_LS)
|
||||||
term.c_lflag &= ~ECHO;
|
term.c_lflag &= ~ECHO;
|
||||||
term.c_cc[VTIME] = data->timeout * 10;
|
|
||||||
term.c_cc[VMIN] = !data->timeout;
|
|
||||||
term.c_cc[VEOL] = data->delim;
|
term.c_cc[VEOL] = data->delim;
|
||||||
if (tcsetattr(0, TCSANOW, &term) < 0)
|
if (tcsetattr(0, TCSANOW, &term) < 0)
|
||||||
|
{
|
||||||
|
SH_ERR("tcsetattr(): %s", strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* builtin_env.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/22 17:17:28 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
#define ENV_USAGE "env [-i] [name=value]... [utility [argument...]]"
|
#define ENV_USAGE "env [-i] [name=value]... [utility [argument...]]"
|
||||||
|
|
@ -51,10 +63,10 @@ int builtin_env(const char *path,
|
||||||
if (!(path = ft_strchr(data.av_data[0], '/') ?
|
if (!(path = ft_strchr(data.av_data[0], '/') ?
|
||||||
ft_strdup(data.av_data[0]) : ft_hash(data.av_data[0]))
|
ft_strdup(data.av_data[0]) : ft_hash(data.av_data[0]))
|
||||||
|| access(path, F_OK) != 0)
|
|| access(path, F_OK) != 0)
|
||||||
exit (SH_ERR(ENV_NOFILE, data.av_data[0]));
|
exit(SH_ERR(ENV_NOFILE, data.av_data[0]));
|
||||||
stat(path, &buf);
|
stat(path, &buf);
|
||||||
if (S_ISDIR(buf.st_mode) || access(path, X_OK) != 0)
|
if (S_ISDIR(buf.st_mode) || access(path, X_OK) != 0)
|
||||||
exit (SH_ERR(ENV_NOPERM, data.av_data[0]));
|
exit(SH_ERR(ENV_NOPERM, data.av_data[0]));
|
||||||
execve(path, data.av_data, data.custom_env);
|
execve(path, data.av_data, data.custom_env);
|
||||||
}
|
}
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 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/21 15:16:34 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:50:14 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
t_cliopts g_read_opts[] =
|
t_cliopts g_read_opts[] =
|
||||||
{
|
{
|
||||||
{'d', NULL, READ_OPT_LD, 0, bt_read_getdelim},
|
{'d', NULL, BT_READ_LD, 0, bt_read_getdelim},
|
||||||
{'n', NULL, READ_OPT_LN, 0, bt_read_getnchars},
|
{'n', NULL, BT_READ_LN, 0, bt_read_getnchars},
|
||||||
{'p', NULL, READ_OPT_LP, 0, bt_read_getprompt},
|
{'p', NULL, BT_READ_LP, 0, bt_read_getprompt},
|
||||||
{'r', NULL, READ_OPT_LR, 0, NULL},
|
{'r', NULL, BT_READ_LR, 0, NULL},
|
||||||
{'s', NULL, READ_OPT_LS, 0, NULL},
|
{'s', NULL, BT_READ_LS, 0, NULL},
|
||||||
{'t', NULL, READ_OPT_LT, 0, bt_read_gettimeout},
|
{'t', NULL, BT_READ_LT, 0, bt_read_gettimeout},
|
||||||
{'u', NULL, READ_OPT_LU, 0, bt_read_getfd},
|
{'u', NULL, BT_READ_LU, 0, bt_read_getfd},
|
||||||
{0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -38,6 +38,8 @@ int bt_read_init(t_read *data, char **av)
|
||||||
data->input = NULL;
|
data->input = NULL;
|
||||||
if ((cliopts_get(av, g_read_opts, data)))
|
if ((cliopts_get(av, g_read_opts, data)))
|
||||||
return (ft_perror() ? 2 : 2);
|
return (ft_perror() ? 2 : 2);
|
||||||
|
if (isatty(STDIN))
|
||||||
|
data->opts |= BT_READ_INTER;
|
||||||
if (bt_read_terminit(data) < 0)
|
if (bt_read_terminit(data) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
@ -52,7 +54,7 @@ int bt_read_loop(t_read *data)
|
||||||
|
|
||||||
esc = 0;
|
esc = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
if (data->prompt)
|
if (data->prompt && data->opts & BT_READ_INTER)
|
||||||
ft_printf(data->prompt);
|
ft_printf(data->prompt);
|
||||||
while (42)
|
while (42)
|
||||||
{
|
{
|
||||||
|
|
@ -61,11 +63,12 @@ int bt_read_loop(t_read *data)
|
||||||
buf[ret] = 0;
|
buf[ret] = 0;
|
||||||
if (!esc && *buf == data->delim)
|
if (!esc && *buf == data->delim)
|
||||||
break ;
|
break ;
|
||||||
esc = esc ? 0 : !(data->opts & READ_OPT_LR) && (*buf == '\\');
|
esc = esc ? 0 : !(data->opts & BT_READ_LR) && (*buf == '\\');
|
||||||
ft_strappend(&data->input, buf);
|
ft_strappend(&data->input, buf);
|
||||||
if (*buf == '\n' && !(data->opts & (READ_OPT_LR | READ_OPT_LS)))
|
if (*buf == '\n' && !(data->opts &
|
||||||
|
(BT_READ_LR | BT_READ_LS | BT_READ_INTER)))
|
||||||
ft_putstr("> ");
|
ft_putstr("> ");
|
||||||
if ((data->opts & READ_OPT_LN) && ++i >= data->nchars)
|
if ((data->opts & BT_READ_LN) && ++i >= data->nchars)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 18:11:31 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:21:49 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
#define SETERR_0 "%s: %s: invalid variable name"
|
#define SETERR_0 "%s: %s: invalid variable name"
|
||||||
|
|
||||||
static int assign_var(char *const av[], char ***env)
|
static int assign_var(char *const av[], char ***env)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/22 16:02:25 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:20:03 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -40,7 +40,6 @@ static char *c_strdupi(char *s, int (*f)(char))
|
||||||
return (str);
|
return (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Seek the current word.
|
** Seek the current word.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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/20 20:40:43 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:09:10 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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/21 20:59:57 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:22:34 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/21 18:11:33 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:34:15 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -45,7 +45,8 @@ int process_launch(t_process *p)
|
||||||
set_exitstatus(1, 1);
|
set_exitstatus(1, 1);
|
||||||
else
|
else
|
||||||
set_exitstatus(p->map.launch(p), 1);
|
set_exitstatus(p->map.launch(p), 1);
|
||||||
process_resetfds(p);
|
shell_resetfds();
|
||||||
|
shell_resetsig();
|
||||||
process_free(p, 0);
|
process_free(p, 0);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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/20 20:41:48 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:24:18 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -67,9 +67,8 @@ int process_set(t_process *p, t_btree *ast)
|
||||||
p->fdout = fds[PIPE_WRITE];
|
p->fdout = fds[PIPE_WRITE];
|
||||||
p->pid = 0;
|
p->pid = 0;
|
||||||
exec->fdin = fds[PIPE_READ];
|
exec->fdin = fds[PIPE_READ];
|
||||||
if (!ast)
|
if (ast)
|
||||||
return (0);
|
p->redirs = ft_lstmap(((t_astnode *)ast->item)->data.cmd.redir,
|
||||||
p->redirs = ft_lstmap(((t_astnode *)ast->item)->data.cmd.redir,
|
|
||||||
&redir_copy);
|
&redir_copy);
|
||||||
return (process_set_spec(p, ast));
|
return ((!ast) ? 0 : process_set_spec(p, ast));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 15:58:33 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:45:57 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,8 +24,7 @@ int process_setgroup(t_process *p, pid_t pid)
|
||||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||||
return (0);
|
return (0);
|
||||||
if (setpgid(pid, j->pgid) == -1)
|
if (setpgid(pid, j->pgid) == -1)
|
||||||
ft_dprintf(2, "{red}%s: internal setpgid() errno=%i{eoc}\n",
|
SH_ERR("setpgid(): %s", strerror(errno));
|
||||||
SHELL_NAME, errno);
|
|
||||||
if (pid == 0 && JOB_IS_FG(j->attrs))
|
if (pid == 0 && JOB_IS_FG(j->attrs))
|
||||||
tcsetpgrp(STDIN, j->pgid);
|
tcsetpgrp(STDIN, j->pgid);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/11 14:08:35 by jhalford #+# #+# */
|
/* Created: 2017/03/11 14:08:35 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/18 00:16:37 by wescande ### ########.fr */
|
/* Updated: 2017/03/22 16:05:27 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/20 14:42:22 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:30:05 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ int builtin_fg(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}fg: %s{eoc}\n", SH_MSG_NOJOBC);
|
SH_ERR("fg: %s", SH_MSG_NOJOBC);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
|
|
@ -33,7 +33,7 @@ int builtin_fg(const char *path, char *const av[], char *const envp[])
|
||||||
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);
|
||||||
else
|
else
|
||||||
ft_dprintf(2, "{red}fg: job not found: [%i]{eoc}\n", id);
|
SH_ERR("{red}fg: job not found: [%i]", id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +42,7 @@ int builtin_fg(const char *path, char *const av[], char *const envp[])
|
||||||
else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id)))
|
else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id)))
|
||||||
job_run(jlist->content, 1);
|
job_run(jlist->content, 1);
|
||||||
else
|
else
|
||||||
ft_dprintf(2, "{red}fg: no current job{eoc}\n");
|
SH_ERR("fg: no current job");
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 14:11:30 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:40:13 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ void process_format(t_list **plist, int firstp, int opts)
|
||||||
|
|
||||||
p = (*plist)->content;
|
p = (*plist)->content;
|
||||||
if (!firstp)
|
if (!firstp)
|
||||||
ft_printf(" ");
|
ft_putstr(" ");
|
||||||
if (opts & JOBS_OPT_L)
|
if (opts & JOBS_OPT_L)
|
||||||
ft_printf("%i ", p->pid);
|
ft_printf("%i ", p->pid);
|
||||||
process_format_state(p);
|
process_format_state(p);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/16 16:51:24 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:32:56 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/19 14:24:38 by wescande #+# #+# */
|
/* Created: 2017/03/19 14:24:38 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 16:44:31 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:37:46 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -34,9 +34,7 @@ int do_lexer_routine(t_list **token, char *stream)
|
||||||
ltoken = ft_lstlast(*token);
|
ltoken = ft_lstlast(*token);
|
||||||
if (lexer_lex(*token ? <oken : token, &data->lexer) < 0)
|
if (lexer_lex(*token ? <oken : token, &data->lexer) < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (get_lexer_stack(data->lexer) > 2)
|
if ((get_lexer_stack(data->lexer) > 2) || (get_reserved_words(*token)))
|
||||||
return (1);
|
|
||||||
if (get_reserved_words(*token))
|
|
||||||
return (1);
|
return (1);
|
||||||
keep_last_type(&last, *token);
|
keep_last_type(&last, *token);
|
||||||
data->lexer.state = DEFAULT;
|
data->lexer.state = DEFAULT;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
|
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/20 16:01:29 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:38:44 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 19:12:50 by ariard #+# #+# */
|
/* Created: 2017/03/20 19:12:50 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/20 19:12:51 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:38:33 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 16:15:34 by ariard #+# #+# */
|
/* Created: 2017/03/20 16:15:34 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/20 16:25:06 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:38:19 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/08 12:14:09 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:16:17 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,10 +24,11 @@ int lexer_paren(t_list **alst, t_lexer *lexer)
|
||||||
token->type = TK_PAREN_OPEN;
|
token->type = TK_PAREN_OPEN;
|
||||||
push(&lexer->stack, PAREN);
|
push(&lexer->stack, PAREN);
|
||||||
}
|
}
|
||||||
else if (get_lexer_stack(*lexer))
|
else
|
||||||
{
|
{
|
||||||
token->type = TK_PAREN_CLOSE;
|
token->type = TK_PAREN_CLOSE;
|
||||||
pop(&lexer->stack);
|
if (get_lexer_stack(*lexer) == PAREN)
|
||||||
|
pop(&lexer->stack);
|
||||||
}
|
}
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
lexer->state = DEFAULT;
|
lexer->state = DEFAULT;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
|
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 20:37:47 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:13:31 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,7 +18,6 @@ void token_print(t_list *lst)
|
||||||
|
|
||||||
while (lst)
|
while (lst)
|
||||||
{
|
{
|
||||||
DG("in token print");
|
|
||||||
if (lst->content)
|
if (lst->content)
|
||||||
token = lst->content;
|
token = lst->content;
|
||||||
if (token->type)
|
if (token->type)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/21 18:11:14 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:49:08 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,17 +43,16 @@ int ft_v(char **str, size_t *pos)
|
||||||
int i;
|
int i;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = data_singleton()->line.copy_tmp;
|
|
||||||
i = -1;
|
i = -1;
|
||||||
tmp_pos = *pos;
|
tmp_pos = *pos;
|
||||||
|
tmp = data_singleton()->line.copy_tmp;
|
||||||
if (!*str || !tmp)
|
if (!*str || !tmp)
|
||||||
return (0);
|
return (0);
|
||||||
while (tmp[++i])
|
while (tmp[++i])
|
||||||
{
|
{
|
||||||
if (ft_strlen(*str) > SIZE_LINE)
|
if (ft_strlen(*str) > SIZE_LINE)
|
||||||
break ;
|
break ;
|
||||||
if (!(*str = ft_realloc_imput(*str, tmp[i], *pos + i)))
|
*str = ft_realloc_imput(*str, tmp[i], *pos + i);
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
if (*pos)
|
if (*pos)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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/20 21:19:20 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 16:49:30 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,10 +21,7 @@ int readline(int has_prompt, char **input)
|
||||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||||
{
|
{
|
||||||
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
|
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
|
||||||
{
|
|
||||||
DG("returning %i", !ret);
|
|
||||||
return (!ret);
|
return (!ret);
|
||||||
}
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
readline_init(has_prompt);
|
readline_init(has_prompt);
|
||||||
|
|
|
||||||
|
|
@ -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/21 01:50:24 by wescande ### ########.fr */
|
/* Updated: 2017/03/22 15:55:07 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -68,8 +68,8 @@ int data_init(int ac, char **av)
|
||||||
parser_init(&data->parser);
|
parser_init(&data->parser);
|
||||||
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
||||||
{
|
{
|
||||||
/* ft_dprintf(2, "{red}TERM not set\n{eoc}"); */
|
|
||||||
term_name = "dumb";
|
term_name = "dumb";
|
||||||
|
/* ft_dprintf(2, "{red}TERM not set\n{eoc}"); */
|
||||||
/* return (-1); */
|
/* return (-1); */
|
||||||
}
|
}
|
||||||
if (tgetent(NULL, term_name) != 1)
|
if (tgetent(NULL, term_name) != 1)
|
||||||
|
|
|
||||||
|
|
@ -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:00:12 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:29:11 by ariard ### ########.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/20 18:12:27 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 16:08:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -71,13 +71,8 @@ static int interactive_settings(void)
|
||||||
shell_pgid = &data->jobc.shell_pgid;
|
shell_pgid = &data->jobc.shell_pgid;
|
||||||
while (tcgetpgrp(STDIN) != (*shell_pgid = getpgrp()))
|
while (tcgetpgrp(STDIN) != (*shell_pgid = getpgrp()))
|
||||||
kill(-*shell_pgid, SIGTTIN);
|
kill(-*shell_pgid, SIGTTIN);
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
signal(SIGQUIT, SIG_IGN);
|
|
||||||
signal(SIGTSTP, SIG_IGN);
|
|
||||||
signal(SIGTTIN, SIG_IGN);
|
|
||||||
signal(SIGTTOU, SIG_IGN);
|
|
||||||
signal(SIGCHLD, SIG_DFL);
|
|
||||||
*shell_pgid = getpid();
|
*shell_pgid = getpid();
|
||||||
|
shell_resetsig();
|
||||||
if (setpgid(*shell_pgid, *shell_pgid))
|
if (setpgid(*shell_pgid, *shell_pgid))
|
||||||
{
|
{
|
||||||
ft_dprintf(2,
|
ft_dprintf(2,
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,32 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* process_resetfds.c :+: :+: :+: */
|
/* shell_reset.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
|
/* Created: 2017/03/22 16:07:14 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 20:54:20 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:25:14 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
void process_resetfds(t_process *p)
|
void shell_resetsig(void)
|
||||||
|
{
|
||||||
|
signal(SIGINT, SIG_IGN);
|
||||||
|
signal(SIGQUIT, SIG_IGN);
|
||||||
|
signal(SIGTSTP, SIG_IGN);
|
||||||
|
signal(SIGTTIN, SIG_IGN);
|
||||||
|
signal(SIGTTOU, SIG_IGN);
|
||||||
|
signal(SIGCHLD, SIG_DFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void shell_resetfds(void)
|
||||||
{
|
{
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void)p;
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
i = -1;
|
i = -1;
|
||||||
while (++i < 10)
|
while (++i < 10)
|
||||||
|
|
@ -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/21 20:01:37 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:52:57 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ t_list *is_already_func(t_btree **new)
|
||||||
while (tmp && ret)
|
while (tmp && ret)
|
||||||
{
|
{
|
||||||
if ((ast = tmp->content) && !*ast)
|
if ((ast = tmp->content) && !*ast)
|
||||||
break;
|
break ;
|
||||||
old_name = token_to_argv(((t_astnode *)
|
old_name = token_to_argv(((t_astnode *)
|
||||||
(*ast)->item)->data.cmd.token, 1);
|
(*ast)->item)->data.cmd.token, 1);
|
||||||
ret = (new_name && new_name[0] && old_name && old_name[0]
|
ret = (new_name && new_name[0] && old_name && old_name[0]
|
||||||
|
|
@ -117,7 +117,7 @@ int add_one_func(t_btree **ast, t_list **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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue