c'est la faute a jack

This commit is contained in:
wescande 2017-03-22 22:26:08 +01:00
parent e4939b9902
commit f836bf2c53
3 changed files with 4 additions and 66 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
/* Updated: 2017/03/22 18:13:32 by jhalford ### ########.fr */
/* Updated: 2017/03/22 22:07:49 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -77,7 +77,6 @@ void token_print(t_list *lst);
int reduce_parens(t_list **alst, char *str);
int bquotes_expand(t_list **alst);
char *command_getoutput(char *command);
int command_setoutput(char *const av[], char **env);
int ft_is_delim(char c);
int ft_is_delim_list(char c);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 18:08:31 by jhalford #+# #+# */
/* Updated: 2017/03/07 18:18:30 by jhalford ### ########.fr */
/* Updated: 2017/03/22 22:23:33 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ char *ft_strtok(char *s, const char *delim)
if ((ch = *s++) == 0)
return (0);
while (ft_strchr(delim, ch))
if ((ch = *s) == 0)
if ((ch = *s++) == 0)
return (0);
--s;
lasts = s + ft_strcspn(s, delim);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 19:44:25 by wescande #+# #+# */
/* Updated: 2017/03/21 18:15:53 by jhalford ### ########.fr */
/* Updated: 2017/03/22 22:25:49 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,55 +29,6 @@ static char *manage_output(int *fds)
return (output);
}
static char *manage_command(char *const av_cmd[])
{
char *command;
int i;
if (!av_cmd)
return (NULL);
i = -1;
command = NULL;
while (av_cmd[++i])
{
if (!command)
command = ft_str3join("\"", av_cmd[i], "\"");
else
command = ft_strjoinf(command, ft_str3join("\"", av_cmd[i], "\""), 3);
}
return (command);
}
static void execute_command(char *const av[], char **env)
{
t_list *token;
t_btree *ast;
t_data *data;
char *command;
token = NULL;
ast = NULL;
data = data_singleton();
data->env = env;
data->opts &= ~SH_INTERACTIVE;
data->opts &= ~SH_OPTS_JOBC;
command = manage_command(av);
DG("DO THE EXEC");
if (do_lexer_routine(&token, command))
{
ft_dprintf(2, "{red}%s: syntax error in command substitution{eoc}\n",
SHELL_NAME);
exit(1);
}
if (do_parser_routine(&token, &ast) <= 0)
{
ft_dprintf(2, "{red}%s: parse error in command substitution{eoc}\n",
SHELL_NAME);
exit(1);
}
exit(data_singleton()->parser.state == SUCCESS && ft_exec(&ast) < 0);
}
char *command_getoutput(char *command)
{
int ret;
@ -101,15 +52,3 @@ char *command_getoutput(char *command)
waitpid(pid, &ret, WUNTRACED);
return (manage_output(fds));
}
int command_setoutput(char *const av[], char **env)
{
int pid;
if (!av)
return (0);
pid = 0;
if (!(pid = process_fork(NULL)))
execute_command(av, env);
return (pid);
}