Merge branch 'master' of github.com:jzck/42sh
This commit is contained in:
commit
08fd57acb5
37 changed files with 135 additions and 119 deletions
30
42sh/error
30
42sh/error
|
|
@ -1,30 +0,0 @@
|
||||||
42sh
|
|
||||||
Makefile
|
|
||||||
STDBUG
|
|
||||||
TESTSHELL
|
|
||||||
donovan_segaults_06-02
|
|
||||||
error
|
|
||||||
includes
|
|
||||||
libft
|
|
||||||
objs
|
|
||||||
pdf
|
|
||||||
sample
|
|
||||||
src
|
|
||||||
test_framework.sh
|
|
||||||
testmake
|
|
||||||
update_makefile.sh
|
|
||||||
42sh
|
|
||||||
Makefile
|
|
||||||
STDBUG
|
|
||||||
TESTSHELL
|
|
||||||
donovan_segaults_06-02
|
|
||||||
error
|
|
||||||
includes
|
|
||||||
libft
|
|
||||||
objs
|
|
||||||
pdf
|
|
||||||
sample
|
|
||||||
src
|
|
||||||
test_framework.sh
|
|
||||||
testmake
|
|
||||||
update_makefile.sh
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 15:14:34 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:31:17 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,6 @@ struct s_redir
|
||||||
int n;
|
int n;
|
||||||
char *word;
|
char *word;
|
||||||
char *heredoc_data;
|
char *heredoc_data;
|
||||||
/* int close; */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct s_cmd
|
struct s_cmd
|
||||||
|
|
|
||||||
|
|
@ -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/09 15:21:14 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 11:58:54 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 15:22:51 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:48:19 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,9 +17,18 @@ int exec_reset(void)
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC);
|
/* exec->fd_save[0] = 1;//fcntl(STDIN, F_DUPFD_CLOEXEC); */
|
||||||
exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC);
|
/* exec->fd_save[1] = 1;//fcntl(STDOUT, F_DUPFD_CLOEXEC); */
|
||||||
exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC);
|
/* exec->fd_save[2] = 1;//fcntl(STDERR, F_DUPFD_CLOEXEC); */
|
||||||
|
DG("check 0");
|
||||||
|
if ((exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
||||||
|
ft_dprintf(2, "{red}%s: internal fcntl STDIN error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||||
|
DG("check 1");
|
||||||
|
if ((exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
||||||
|
ft_dprintf(2, "{red}%s: internal fcntl STDOUT error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||||
|
if ((exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
||||||
|
ft_dprintf(2, "{red}%s: internal fcntl STDERR error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||||
|
DG("saved [%i:%i:%i]", exec->fd_save[0], exec->fd_save[1], exec->fd_save[2]);
|
||||||
exec->op_stack = NULL;
|
exec->op_stack = NULL;
|
||||||
exec->fdin = STDIN;
|
exec->fdin = STDIN;
|
||||||
exec->attrs = 0;
|
exec->attrs = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,18 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */
|
/* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/06 16:58:38 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:59:28 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int fd_is_valid(int fd, int has_flag)
|
int fd_is_valid(int fd, int has_mode)
|
||||||
{
|
{
|
||||||
int flags;
|
int fd_flags;
|
||||||
|
int fd_modes;
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
fd_modes = fcntl(fd, F_GETFL);
|
||||||
return ((flags != -1 || errno != EBADF) && flags & has_flag);
|
fd_flags = fcntl(fd, F_GETFD);
|
||||||
|
return ((fd_flags != -1 || errno != EBADF) && fd_modes & has_mode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 15:10:15 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 12:12:59 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 15:15:33 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 11:58:53 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 15:08:04 by wescande ### ########.fr */
|
/* Updated: 2017/03/10 11:51:55 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/08 18:49:49 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 12:51:05 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,8 +18,6 @@ int mark_process_status(pid_t pid, int status)
|
||||||
t_process *p;
|
t_process *p;
|
||||||
|
|
||||||
DG("MPS pid=%i,s=%i", pid, status);
|
DG("MPS pid=%i,s=%i", pid, status);
|
||||||
if (pid > 1)
|
|
||||||
{
|
|
||||||
if ((plist = job_getprocess(pid)))
|
if ((plist = job_getprocess(pid)))
|
||||||
{
|
{
|
||||||
p = plist->content;
|
p = plist->content;
|
||||||
|
|
@ -42,6 +40,4 @@ int mark_process_status(pid_t pid, int status)
|
||||||
}
|
}
|
||||||
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
|
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 15:20:41 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:09:25 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,9 +15,13 @@
|
||||||
void process_resetfds(t_process *p)
|
void process_resetfds(t_process *p)
|
||||||
{
|
{
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
|
int i;
|
||||||
|
|
||||||
(void)p;
|
(void)p;
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
|
i = 0;
|
||||||
|
while (i < 10)
|
||||||
|
close(i++);
|
||||||
dup2(exec->fd_save[0], STDIN);
|
dup2(exec->fd_save[0], STDIN);
|
||||||
dup2(exec->fd_save[1], STDOUT);
|
dup2(exec->fd_save[1], STDOUT);
|
||||||
dup2(exec->fd_save[2], STDERR);
|
dup2(exec->fd_save[2], STDERR);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ int redirect_dless(t_redir *redir)
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
pipe(fds);
|
pipe(fds);
|
||||||
str = redir->word;
|
str = redir->heredoc_data;
|
||||||
|
DG("[%s]", str);
|
||||||
write(fds[PIPE_WRITE], str, ft_strlen(str));
|
write(fds[PIPE_WRITE], str, ft_strlen(str));
|
||||||
close(fds[PIPE_WRITE]);
|
close(fds[PIPE_WRITE]);
|
||||||
dup2(fds[PIPE_READ], 0);
|
dup2(fds[PIPE_READ], 0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/06 16:54:43 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 14:01:06 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,14 +17,14 @@ int redirect_greatand(t_redir *redir)
|
||||||
int fdold;
|
int fdold;
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
if (ft_strcmp(redir->word, "-"))
|
if (ft_strcmp(redir->word, "-") == 0)
|
||||||
{
|
{
|
||||||
close(redir->n);
|
close(redir->n);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (!ft_stris(redir->word, ft_isdigit))
|
if (!ft_stris(redir->word, ft_isdigit))
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "%s: %s: can only be digits", SHELL_NAME, redir->word);
|
ft_dprintf(2, "{red}%s: %s: can only be digits{eoc}\n", SHELL_NAME, redir->word);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
fdold = ft_atoi(redir->word);
|
fdold = ft_atoi(redir->word);
|
||||||
|
|
@ -33,9 +33,10 @@ int redirect_greatand(t_redir *redir)
|
||||||
return (0);
|
return (0);
|
||||||
if (fdold > 9)
|
if (fdold > 9)
|
||||||
return (bad_fd(fdold));
|
return (bad_fd(fdold));
|
||||||
if (fd_is_valid(fdold, O_RDONLY))
|
if (fd_is_valid(fdold, O_RDONLY | O_RDWR))
|
||||||
dup2_close(fdold, fdnew);
|
dup2_close(fdold, fdnew);
|
||||||
else
|
else
|
||||||
return (bad_fd(fdold));
|
close(fdnew);
|
||||||
|
/* return (bad_fd(fdold)); */
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/06 16:53:29 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 14:00:40 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,14 +17,14 @@ int redirect_lessand(t_redir *redir)
|
||||||
int fdold;
|
int fdold;
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
if (ft_strcmp(redir->word, "-"))
|
if (ft_strcmp(redir->word, "-") == 0)
|
||||||
{
|
{
|
||||||
close(redir->n);
|
close(redir->n);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (!ft_stris(redir->word, ft_isdigit))
|
if (!ft_stris(redir->word, ft_isdigit))
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "%s: %s: can only be digits", SHELL_NAME, redir->word);
|
ft_dprintf(2, "{red}%s: %s: can only be digits{eoc}\n", SHELL_NAME, redir->word);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
fdold = ft_atoi(redir->word);
|
fdold = ft_atoi(redir->word);
|
||||||
|
|
@ -33,9 +33,10 @@ int redirect_lessand(t_redir *redir)
|
||||||
return (0);
|
return (0);
|
||||||
if (fdold > 9)
|
if (fdold > 9)
|
||||||
return (bad_fd(fdold));
|
return (bad_fd(fdold));
|
||||||
if (fd_is_valid(fdold, O_WRONLY))
|
if (fd_is_valid(fdold, O_WRONLY | O_RDWR))
|
||||||
dup2_close(fdold, fdnew);
|
dup2_close(fdold, fdnew);
|
||||||
else
|
else
|
||||||
return (bad_fd(fdold));
|
close(fdnew);
|
||||||
|
/* return (bad_fd(fdold)); */
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/14 11:27:03 by gwojda #+# #+# */
|
/* Created: 2017/02/14 11:27:03 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/04 15:52:19 by gwojda ### ########.fr */
|
/* Updated: 2017/03/10 12:59:26 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,17 +15,26 @@
|
||||||
void ft_add_in_history_file(char *str)
|
void ft_add_in_history_file(char *str)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
int i;
|
||||||
char *home;
|
char *home;
|
||||||
char *path;
|
char *path;
|
||||||
|
char **hist;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
hist = ft_strsplit(str, '\n');
|
||||||
if (!(home = ft_getenv(data_singleton()->env, "HOME")))
|
if (!(home = ft_getenv(data_singleton()->env, "HOME")))
|
||||||
return ;
|
return ;
|
||||||
path = ft_str3join(home, "/", ".42sh_history");
|
path = ft_str3join(home, "/", ".42sh_history");
|
||||||
fd = open(path, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR);
|
fd = open(path, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return ;
|
return ;
|
||||||
write(fd, str, ft_strlen(str));
|
while (hist[i])
|
||||||
|
{
|
||||||
|
write(fd, hist[i], ft_strlen(str));
|
||||||
write(fd, "\n", 1);
|
write(fd, "\n", 1);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
ft_sstrfree(hist);
|
||||||
free(path);
|
free(path);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 20:35:18 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 12:40:35 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 20:35:12 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 12:41:11 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,5 +22,5 @@ void job_update_status(void)
|
||||||
pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG);
|
pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG);
|
||||||
DG("pid=[%d]", pid);
|
DG("pid=[%d]", pid);
|
||||||
}
|
}
|
||||||
while (!mark_process_status(pid, status));
|
while (pid > 1 && !mark_process_status(pid, status));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 20:37:28 by jhalford #+# #+# */
|
/* Created: 2017/02/09 20:37:28 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/24 20:44:40 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:12:51 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:35 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:06:35 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 12:10:46 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:11:30 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,8 +17,8 @@ int lexer_great(t_list **alst, t_lexer *lexer)
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
token = (*alst)->content;
|
token = (*alst)->content;
|
||||||
/* if (token->type) */
|
if (token->type)
|
||||||
/* return (lexer_lex(&(*alst)->next, lexer)); */
|
return (lexer_lex(&(*alst)->next, lexer));
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
if (lexer->str[lexer->pos] == '&')
|
if (lexer->str[lexer->pos] == '&')
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 11:56:58 by jhalford #+# #+# */
|
/* Created: 2016/12/03 11:56:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 23:34:08 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:45:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 15:51:17 by jhalford #+# #+# */
|
/* Created: 2017/03/08 15:51:17 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 23:19:57 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:27:32 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 23:34:58 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:11:27 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,6 +17,8 @@ int lexer_less(t_list **alst, t_lexer *lexer)
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
token = (*alst)->content;
|
token = (*alst)->content;
|
||||||
|
if (token->type)
|
||||||
|
return (lexer_lex(&(*alst)->next, lexer));
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
if (lexer->str[lexer->pos] == '&')
|
if (lexer->str[lexer->pos] == '&')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 23:35:37 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:12:43 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ int lexer_number(t_list **alst, t_lexer *lexer)
|
||||||
{
|
{
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
return (lexer_lex(&(*alst)->next, lexer));
|
return (lexer_lex(alst, lexer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */
|
/* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:11:35 by jhalford ### ########.fr */
|
/* Updated: 2017/03/09 18:48:00 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -31,6 +31,8 @@ int lexer_sep(t_list **alst, t_lexer *lexer)
|
||||||
token->type = cn == '|' ? TK_OR_IF : TK_PIPE;
|
token->type = cn == '|' ? TK_OR_IF : TK_PIPE;
|
||||||
else if (c == ';')
|
else if (c == ';')
|
||||||
token->type = cn == ';' ? TK_DSEMI : TK_SEMI;
|
token->type = cn == ';' ? TK_DSEMI : TK_SEMI;
|
||||||
|
else if (c == '!')
|
||||||
|
token->type = TK_BANG;
|
||||||
if (token->type == TK_AND_IF || token->type == TK_OR_IF
|
if (token->type == TK_AND_IF || token->type == TK_OR_IF
|
||||||
|| token->type == TK_DSEMI)
|
|| token->type == TK_DSEMI)
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
|
|
|
||||||
|
|
@ -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/09 15:23:31 by jhalford ### ########.fr */
|
/* Updated: 2017/03/10 13:48:20 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/07 23:35:32 by ariard ### ########.fr */
|
/* Updated: 2017/03/09 18:54:07 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,8 +17,12 @@ char *ft_putast(void *nodein)
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
node = nodein;
|
node = nodein;
|
||||||
|
|
||||||
|
if (node->type == TK_BANG)
|
||||||
|
return ("TK_BANG");
|
||||||
if (node->type == MATH)
|
if (node->type == MATH)
|
||||||
return ("MATH");
|
return ("MATH");
|
||||||
|
if (node->type == MATH_PLUS)
|
||||||
|
return ("MATH_PLUS");
|
||||||
if (node->type == TK_DSEMI)
|
if (node->type == TK_DSEMI)
|
||||||
return ("TK_DSEMI");
|
return ("TK_DSEMI");
|
||||||
if (node->type == WORDLIST)
|
if (node->type == WORDLIST)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/09 17:37:38 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:31:16 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -36,6 +36,11 @@ int handle_instruction(int fd)
|
||||||
return (parser.state == UNDEFINED ? error_EOF(&token,
|
return (parser.state == UNDEFINED ? error_EOF(&token,
|
||||||
&parser, &ast) : 1);
|
&parser, &ast) : 1);
|
||||||
}
|
}
|
||||||
|
if (lexer.state == HEREDOC)
|
||||||
|
{
|
||||||
|
ft_strappend(&lexer.str, (char[]){'\n', 0});
|
||||||
|
lexer.pos++;
|
||||||
|
}
|
||||||
ft_strappend(&lexer.str, str);
|
ft_strappend(&lexer.str, str);
|
||||||
if (get_lexer_stack(lexer) == BACKSLASH)
|
if (get_lexer_stack(lexer) == BACKSLASH)
|
||||||
pop(&lexer.stack);
|
pop(&lexer.stack);
|
||||||
|
|
@ -109,14 +114,14 @@ int main(int ac, char **av)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
DG("{inv}{bol}{gre}start of shell{eoc}");
|
||||||
shell_init(ac, av);
|
shell_init(ac, av);
|
||||||
if ((fd = get_input_fd()) < 0)
|
if ((fd = get_input_fd()) < 0)
|
||||||
{
|
{
|
||||||
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
|
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s, fd=[%i]",
|
DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
||||||
SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
|
||||||
while (handle_instruction(fd) == 0)
|
while (handle_instruction(fd) == 0)
|
||||||
{
|
{
|
||||||
DG();
|
DG();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 23:42:47 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 12:12:30 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,6 +17,7 @@ void shell_init(int ac, char **av)
|
||||||
int *shell_pgid;
|
int *shell_pgid;
|
||||||
t_data *data;
|
t_data *data;
|
||||||
|
|
||||||
|
DG("check");
|
||||||
data_init();
|
data_init();
|
||||||
data = data_singleton();
|
data = data_singleton();
|
||||||
data->argc = ac;
|
data->argc = ac;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/09 16:04:46 by ariard ### ########.fr */
|
/* Updated: 2017/03/09 19:44:51 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
|
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/09 18:29:45 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:45:42 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
|
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/07 22:46:36 by ariard ### ########.fr */
|
/* Updated: 2017/03/09 19:46:44 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,6 +23,8 @@ int issubshell(t_btree **ast, t_list **lst)
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
if (node->type == SUBSHELL && node->full == 0)
|
if (node->type == SUBSHELL && node->full == 0)
|
||||||
return (1);
|
return (1);
|
||||||
|
if (node->type == TK_LBRACE && node->full == 0)
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ t_aggrematch g_aggrematch[] =
|
||||||
{NEWLINE_LIST, TK_ELIF, TK_ELIF, TK_ELIF},
|
{NEWLINE_LIST, TK_ELIF, TK_ELIF, TK_ELIF},
|
||||||
{NEWLINE_LIST, TK_ELSE, TK_ELSE, TK_ELSE},
|
{NEWLINE_LIST, TK_ELSE, TK_ELSE, TK_ELSE},
|
||||||
{NEWLINE_LIST, TK_WHILE, TK_WHILE, TK_WHILE},
|
{NEWLINE_LIST, TK_WHILE, TK_WHILE, TK_WHILE},
|
||||||
|
{NEWLINE_LIST, TK_LBRACE, TK_LBRACE, TK_LBRACE},
|
||||||
{NEWLINE_LIST, TK_UNTIL, TK_UNTIL, TK_UNTIL},
|
{NEWLINE_LIST, TK_UNTIL, TK_UNTIL, TK_UNTIL},
|
||||||
{NEWLINE_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
{NEWLINE_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
||||||
{NEWLINE_LIST, NEWLINE_LIST, NEWLINE_LIST, NEWLINE},
|
{NEWLINE_LIST, NEWLINE_LIST, NEWLINE_LIST, NEWLINE},
|
||||||
|
|
@ -367,21 +368,21 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
|
||||||
return (1);
|
return (1);
|
||||||
i = 0;
|
i = 0;
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
// DG("aggregate head %s && sym %s",
|
DG("aggregate head %s && sym %s",
|
||||||
// read_state(*head), read_state(*new_sym));
|
read_state(*head), read_state(*new_sym));
|
||||||
while (g_aggrematch[i].top)
|
while (g_aggrematch[i].top)
|
||||||
{
|
{
|
||||||
if (*new_sym == g_aggrematch[i].top
|
if (*new_sym == g_aggrematch[i].top
|
||||||
&& MATCH_STACK(*head, g_aggrematch[i].under))
|
&& MATCH_STACK(*head, g_aggrematch[i].under))
|
||||||
|
|
||||||
{
|
{
|
||||||
// DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
|
DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
|
||||||
*new_sym = g_aggrematch[i].new_sym;
|
*new_sym = g_aggrematch[i].new_sym;
|
||||||
if (g_aggrematch[i].erase_sym)
|
if (g_aggrematch[i].erase_sym)
|
||||||
{
|
{
|
||||||
pop_stack(stack, g_aggrematch[i].erase_sym);
|
pop_stack(stack, g_aggrematch[i].erase_sym);
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
// DG("stack after pop: %s", read_state(*head));
|
DG("stack after pop: %s", read_state(*head));
|
||||||
}
|
}
|
||||||
if (eval_sym(stack, *new_sym))
|
if (eval_sym(stack, *new_sym))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/09 18:33:05 by ariard ### ########.fr */
|
/* Updated: 2017/03/09 19:45:53 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,7 @@ t_stackmatch g_stackmatch[] =
|
||||||
// watch !
|
// watch !
|
||||||
{TK_PAREN_OPEN, AND_OR_MAJOR},
|
{TK_PAREN_OPEN, AND_OR_MAJOR},
|
||||||
{TK_PAREN_OPEN, TK_WHILE},
|
{TK_PAREN_OPEN, TK_WHILE},
|
||||||
|
{TK_PAREN_OPEN, TK_LBRACE},
|
||||||
{TK_PAREN_OPEN, FUNC_NAME},
|
{TK_PAREN_OPEN, FUNC_NAME},
|
||||||
{TK_PAREN_OPEN, TK_UNTIL},
|
{TK_PAREN_OPEN, TK_UNTIL},
|
||||||
{TK_PAREN_OPEN, TK_DO},
|
{TK_PAREN_OPEN, TK_DO},
|
||||||
|
|
@ -817,6 +818,7 @@ t_stackmatch g_stackmatch[] =
|
||||||
{WHILE_CLAUSE, TK_DO},
|
{WHILE_CLAUSE, TK_DO},
|
||||||
{WHILE_CLAUSE, TK_PAREN_CLOSE},
|
{WHILE_CLAUSE, TK_PAREN_CLOSE},
|
||||||
{WHILE_CLAUSE, TK_WHILE},
|
{WHILE_CLAUSE, TK_WHILE},
|
||||||
|
{WHILE_CLAUSE, TK_LBRACE},
|
||||||
{WHILE_CLAUSE, FUNC_NAME},
|
{WHILE_CLAUSE, FUNC_NAME},
|
||||||
{WHILE_CLAUSE, TK_UNTIL},
|
{WHILE_CLAUSE, TK_UNTIL},
|
||||||
{WHILE_CLAUSE, TK_IF},
|
{WHILE_CLAUSE, TK_IF},
|
||||||
|
|
@ -954,6 +956,7 @@ t_stackmatch g_stackmatch[] =
|
||||||
{SUBSHELL, SEPARATOR_OP},
|
{SUBSHELL, SEPARATOR_OP},
|
||||||
{SUBSHELL, NEWLINE_LIST},
|
{SUBSHELL, NEWLINE_LIST},
|
||||||
{SUBSHELL, SEQUENCE},
|
{SUBSHELL, SEQUENCE},
|
||||||
|
{SUBSHELL, TK_LBRACE},
|
||||||
// watch !
|
// watch !
|
||||||
{SUBSHELL, SEPARATOR_OP},
|
{SUBSHELL, SEPARATOR_OP},
|
||||||
{SUBSHELL, NEWLINE_LIST},
|
{SUBSHELL, NEWLINE_LIST},
|
||||||
|
|
@ -1059,8 +1062,6 @@ t_stackmatch g_stackmatch[] =
|
||||||
{TK_BANG, TK_PAREN_OPEN},
|
{TK_BANG, TK_PAREN_OPEN},
|
||||||
{TK_BANG, TK_LBRACE},
|
{TK_BANG, TK_LBRACE},
|
||||||
{TK_BANG, COMPLETE_COMMANDS},
|
{TK_BANG, COMPLETE_COMMANDS},
|
||||||
{TK_BANG, TK_BANG},
|
|
||||||
{TK_BANG, TK_BANG},
|
|
||||||
{TK_BANG, SEPARATOR_OP},
|
{TK_BANG, SEPARATOR_OP},
|
||||||
{TK_BANG, NEWLINE_LIST},
|
{TK_BANG, NEWLINE_LIST},
|
||||||
{TK_BANG, AND_OR_MAJOR},
|
{TK_BANG, AND_OR_MAJOR},
|
||||||
|
|
@ -1191,7 +1192,7 @@ int eval_sym(t_list **stack, t_sym new_sym)
|
||||||
if (!*stack)
|
if (!*stack)
|
||||||
return (1);
|
return (1);
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
// DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
||||||
i = 0;
|
i = 0;
|
||||||
while (g_stackmatch[i].top)
|
while (g_stackmatch[i].top)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:21:05 by ariard #+# #+# */
|
/* Created: 2017/03/08 16:21:05 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/09 17:34:31 by ariard ### ########.fr */
|
/* Updated: 2017/03/10 13:33:29 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -26,15 +26,21 @@ int pop_heredoc(t_list **lst)
|
||||||
head = data_singleton()->heredoc_queue->content;
|
head = data_singleton()->heredoc_queue->content;
|
||||||
temp = data_singleton()->heredoc_queue;
|
temp = data_singleton()->heredoc_queue;
|
||||||
DG("compare %s with %s", (char *)token->data, head->word);
|
DG("compare %s with %s", (char *)token->data, head->word);
|
||||||
if (head && token && ft_strcmp((char *)token->data, head->word) == 0)
|
if (head && token)
|
||||||
{
|
{
|
||||||
DG();
|
DG();
|
||||||
|
if (ft_strcmp((char *)token->data, head->word) == 0)
|
||||||
|
{
|
||||||
temp2 = temp->next;
|
temp2 = temp->next;
|
||||||
free(temp);
|
free(temp);
|
||||||
data_singleton()->heredoc_queue = temp2;
|
data_singleton()->heredoc_queue = temp2;
|
||||||
}
|
}
|
||||||
else if (token)
|
else
|
||||||
|
{
|
||||||
|
DG("joining [%s] to heredoc", (char*)token->data);
|
||||||
head->heredoc_data = ft_strjoin(head->heredoc_data, token->data);
|
head->heredoc_data = ft_strjoin(head->heredoc_data, token->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
ft_lstdel(lst, &token_free);
|
ft_lstdel(lst, &token_free);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue