Commit 8c848d77 authored by abenoit's avatar abenoit
Browse files

multiple fixes

parent 69ebbccd
......@@ -11,7 +11,6 @@ enum e_retcode
CLEAN_EXIT,
ARG_ERR,
FT_EXIT,
PIPE_EXIT,
CHILD_EXIT,
CHILD_ERROR,
_ERRNO_MSG_,
......@@ -37,7 +36,8 @@ enum e_retcode
ESCAPE_NL,
REDIR_PATH_INVALID,
REDIR_PATH_MISSING,
EMPTY_CMD
EMPTY_CMD,
PIPE_EXIT
};
int clean_and_exit(int ret, t_xe *xe);
......
......@@ -7,22 +7,7 @@ builtins: set stat_loc for all returns
arthur:
===========================??? oui on peut pas delete l'input en cours, et ensuite si on fait CTRL-C on peut plus refaire tout de suite CTRL-D
CTRL-D apres avoir ecrit un debut de cmd
"cat | exit"======>ne devrait pas exit
=======================> if (pipe)
{ if (cmd == exit)
{ no exit } }
=================> info non accessibles dans le process parent, mettre un flag dans xe pour passer l'info à la commande suivante
continue commands after HOME_NOT_SET and CD_ARG_ERR
"echo | echo pouet"
ou "ls | echo pouet"
comportement simplifié ^D
masaki:
......
......@@ -81,12 +81,13 @@ int parent_pipe_end(t_command *cur_command, t_xe *xe, int fd_in, int proc)
xe->stat_loc = WEXITSTATUS(xe->stat_loc);
i++;
}
if (ret != SUCCESS)
if (ret != SUCCESS && ret < _ERRNO_MSG_)
return (ret);
else
{
xe->pipe = 0;
xe->stat_loc = tmp;
ft_error(ret, xe);
return (handle_execution(xe, STDIN_FILENO, 0));
}
}
......
......@@ -242,14 +242,11 @@ int execute_cmd(char **args, char **redir_paths, enum e_redir_op *redir_types,
if (ret != SUCCESS)
return (ret);
}
// printf("arg0 = %s\n", args[0]);
cmd_code = get_cmd_code(args[0]);
if (cmd_code == M_ERROR)
return (MALLOC_ERR);
else if (cmd_code == EXIT && xe->pipe & CMD_PIPE)
return (PIPE_EXIT);
ret = command[cmd_code](args, xe);
if (ret >= HOME_NOT_SET)// ?
return (ret);// ?
return (ret);
}
......@@ -4,23 +4,6 @@
#include "execution.h"
#include "builtins.h"
static int handle_eof(char **line, int ret)
{
char *tmp;
char *ptr;
while (ret != SUCCESS)
{
ft_putstr_fd(" \b\b", STDIN_FILENO);
ret = get_next_line(STDIN_FILENO, &tmp);
ptr = *line;
*line = ft_strjoin(ptr, tmp);
free(ptr);
free(tmp);
}
return (ret);
}
static int get_input(char **line)
{
int ret;
......@@ -35,13 +18,8 @@ static int get_input(char **line)
return (GNL_ERR);
else if (ret == 0) // EOF in files and heredocs (noeol files not yet supported)
{
if (ft_strcmp(*line, "") == 0)
{
free(*line);
return (CLEAN_EXIT);
}
else
return (handle_eof(line, ret));
}
return (SUCCESS);
}
......
......@@ -3,8 +3,7 @@
void sig_int(int signum)
{
(void)signum;
// ft_putstr_fd("\b\b \b\b", STDOUT_FILENO);
ft_putstr_fd("\n", STDOUT_FILENO);
ft_putstr_fd("\n", STDIN_FILENO);
if (ft_putstr_fd(FT_PS1, STDOUT_FILENO) == ERROR)
return ;
}
......@@ -12,11 +11,7 @@ void sig_int(int signum)
void sig_kill(int signum)
{
(void)signum;
ft_putstr_fd("\b\b \b\b", STDOUT_FILENO);
// ft_putstr_fd("\b\b \b\b", STDOUT_FILENO);
// ft_putstr_fd("\n", STDOUT_FILENO);
// if (ft_putstr_fd(FT_PS1, STDOUT_FILENO) == ERROR)
// return ;
ft_putstr_fd("\b\b \b\b", STDIN_FILENO);
}
void signal_handler(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment