fix ret
This commit is contained in:
parent
50b63411bf
commit
ec1272258d
4
Makefile
4
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/03/06 12:50:24 by apommier #+# #+# #
|
# Created: 2022/03/06 12:50:24 by apommier #+# #+# #
|
||||||
# Updated: 2022/04/15 12:36:24 by apommier ### ########.fr #
|
# Updated: 2022/04/16 02:25:09 by apommier ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ SRCS = srcs/main.c\
|
|||||||
srcs/set_cmd/set_cmd.c\
|
srcs/set_cmd/set_cmd.c\
|
||||||
srcs/set_redirection/redirection.c\
|
srcs/set_redirection/redirection.c\
|
||||||
srcs/set_redirection/utils.c\
|
srcs/set_redirection/utils.c\
|
||||||
srcs/built_in/exit.c\
|
|
||||||
srcs/built_in/unset.c\
|
srcs/built_in/unset.c\
|
||||||
srcs/built_in/cd.c\
|
srcs/built_in/cd.c\
|
||||||
srcs/built_in/echo.c\
|
srcs/built_in/echo.c\
|
||||||
@ -27,6 +26,7 @@ SRCS = srcs/main.c\
|
|||||||
srcs/built_in/init_builtin.c\
|
srcs/built_in/init_builtin.c\
|
||||||
srcs/built_in/export2.c\
|
srcs/built_in/export2.c\
|
||||||
srcs/built_in/env.c\
|
srcs/built_in/env.c\
|
||||||
|
srcs/built_in/exit.c\
|
||||||
srcs/set_quote/split_with_quote.c\
|
srcs/set_quote/split_with_quote.c\
|
||||||
srcs/set_quote/set_quote.c\
|
srcs/set_quote/set_quote.c\
|
||||||
srcs/built_in/choose_builtin.c
|
srcs/built_in/choose_builtin.c
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/03/09 22:33:49 by apommier #+# #+# */
|
/* Created: 2022/03/09 22:33:49 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 12:33:26 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:39:21 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ char **ft_dup_double(char **env);
|
|||||||
void execute(t_cmd *cmd, char **env);
|
void execute(t_cmd *cmd, char **env);
|
||||||
|
|
||||||
//set_cmd.c
|
//set_cmd.c
|
||||||
t_cmd *set_cmd(char *input, char **path);
|
t_cmd *set_cmd(char *input, char **path, int nb);
|
||||||
|
|
||||||
//pipex_utils.c
|
//pipex_utils.c
|
||||||
char **get_path(char **env);
|
char **get_path(char **env);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/02/28 17:12:52 by sadjigui #+# #+# */
|
/* Created: 2022/02/28 17:12:52 by sadjigui #+# #+# */
|
||||||
/* Updated: 2022/04/15 12:35:45 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:26:33 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/04/15 11:23:32 by apommier #+# #+# */
|
/* Created: 2022/04/15 11:23:32 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 13:02:34 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:19:58 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
10
srcs/main.c
10
srcs/main.c
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/03/06 13:27:11 by apommier #+# #+# */
|
/* Created: 2022/03/06 13:27:11 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 12:34:32 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:42:24 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -60,10 +60,9 @@ void print_prompt(char **path)
|
|||||||
cmd = 0;
|
cmd = 0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
i = 0;
|
|
||||||
input = readline("\033[1;31m~$ \033[0m");
|
input = readline("\033[1;31m~$ \033[0m");
|
||||||
/*if (!input)
|
if (!input)
|
||||||
exit_shell(cmd);*/
|
exit_shell(cmd, 0);
|
||||||
add_history(input);
|
add_history(input);
|
||||||
/*if (!ft_strcmp("exit", input) && input)
|
/*if (!ft_strcmp("exit", input) && input)
|
||||||
{
|
{
|
||||||
@ -72,7 +71,7 @@ void print_prompt(char **path)
|
|||||||
}*/
|
}*/
|
||||||
if (ft_strlen(input) && next_space(input, 0) && input)
|
if (ft_strlen(input) && next_space(input, 0) && input)
|
||||||
{
|
{
|
||||||
cmd = set_cmd(input, path);
|
cmd = set_cmd(input, path, i);
|
||||||
if (cmd)
|
if (cmd)
|
||||||
{
|
{
|
||||||
cmd->err_var = 0;
|
cmd->err_var = 0;
|
||||||
@ -84,6 +83,7 @@ void print_prompt(char **path)
|
|||||||
else
|
else
|
||||||
ft_putstr_fd("Minishell: error while parsing command\n", 2);
|
ft_putstr_fd("Minishell: error while parsing command\n", 2);
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
free(input);
|
free(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/04/02 18:51:31 by apommier #+# #+# */
|
/* Created: 2022/04/02 18:51:31 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 11:22:50 by apommier ### ########.fr */
|
/* Updated: 2022/04/15 06:29:09 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/03/09 12:33:30 by apommier #+# #+# */
|
/* Created: 2022/03/09 12:33:30 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 12:55:45 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:41:51 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,20 +15,17 @@
|
|||||||
void exit_shell(t_cmd *cmd, int ret)
|
void exit_shell(t_cmd *cmd, int ret)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char ret_exit;
|
|
||||||
|
|
||||||
ret_exit = (unsigned char)ret;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
/*if (cmd)
|
if (cmd)
|
||||||
free_double(cmd->env);*/
|
free_double(cmd->env);
|
||||||
free_cmd(cmd);
|
|
||||||
clear_history();
|
clear_history();
|
||||||
//print_double_fd(cmd->s_cmds[0]->env, 1);
|
//print_double_fd(cmd->s_cmds[0]->env, 1);
|
||||||
ft_putstr_fd("exit\n", 1);
|
ft_putstr_fd("exit\n", 1);
|
||||||
//if (cmd->path)
|
//if (cmd->path)
|
||||||
//free_double(cmd->path);
|
//free_double(cmd->path);
|
||||||
cmd = 0;
|
cmd = 0;
|
||||||
exit(ret_exit);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_cmd(t_cmd *cmd)
|
void free_cmd(t_cmd *cmd)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/03/08 15:19:42 by apommier #+# #+# */
|
/* Created: 2022/03/08 15:19:42 by apommier #+# #+# */
|
||||||
/* Updated: 2022/04/15 06:00:35 by apommier ### ########.fr */
|
/* Updated: 2022/04/16 02:39:13 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ int is_pipe_good(char *str)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_cmd *set_cmd(char *input, char **env)
|
t_cmd *set_cmd(char *input, char **env, int nb)
|
||||||
{
|
{
|
||||||
t_cmd *cmd;
|
t_cmd *cmd;
|
||||||
char **cmds;
|
char **cmds;
|
||||||
@ -115,9 +115,12 @@ t_cmd *set_cmd(char *input, char **env)
|
|||||||
cmd = malloc(sizeof(t_cmd));
|
cmd = malloc(sizeof(t_cmd));
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return (0);
|
return (0);
|
||||||
|
//cmd->err_var = 0;
|
||||||
cmd->s_cmds = calloc(sizeof(t_s_cmd), double_size(cmds) + 1);
|
cmd->s_cmds = calloc(sizeof(t_s_cmd), double_size(cmds) + 1);
|
||||||
if (!cmd->s_cmds)
|
if (!cmd->s_cmds)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (nb == 0)
|
||||||
|
cmd->err_var = 0;
|
||||||
cmd->path = 0;
|
cmd->path = 0;
|
||||||
//cmd->s_cmds[double_size(cmds)] = NULL;
|
//cmd->s_cmds[double_size(cmds)] = NULL;
|
||||||
cmd->path = get_path(env);
|
cmd->path = get_path(env);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user