stopped caring 20 commits ago

This commit is contained in:
2024-03-23 18:07:17 +01:00
parent 568df14b4a
commit d4a95a0d76
6 changed files with 27 additions and 22 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */
/* Updated: 2024/03/23 10:18:36 by marde-vr ### ########.fr */
/* Updated: 2024/03/23 17:57:20 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,7 +32,7 @@ int cmd_is_builtin(t_msh *msh, char *cmd_token)
}
else if (!ft_strcmp(cmd_token, "unalias"))
{
unalias(msh);
g_return_code = unalias(msh);
return (1);
}
else if (!ft_strcmp(cmd_token, "alias"))
@ -48,7 +48,7 @@ int cmd_is_builtin(t_msh *msh, char *cmd_token)
else if(!ft_strcmp(cmd_token,"export"))
{
if (!(msh->in_type == PIPE || msh->out_type == PIPE))
ft_export(msh);
g_return_code = ft_export(msh);
return(1);
}
else if(!ft_strcmp(cmd_token, "unset"))
@ -62,7 +62,7 @@ int cmd_is_builtin(t_msh *msh, char *cmd_token)
int exec_builtin(t_msh *msh)
{
if (!msh->cmds->token)
return (STDIN_FILENO);
return (0);
if (!ft_strcmp(msh->cmds->token, "echo"))
g_return_code = echo(msh->cmds->next);
else if (!ft_strcmp(msh->cmds->token, "ret"))
@ -75,15 +75,11 @@ int exec_builtin(t_msh *msh)
g_return_code = pwd();
else if (!ft_strcmp(msh->cmds->token, "cd"))
g_return_code = cd(msh->cmds);
// else if (!ft_strcmp(msh->cmds->token, "export"))
// g_return_code = ft_export(msh);
// else if (!ft_strcmp(msh->cmds->token, "unset"))
// g_return_code = ft_unset(msh);
else if (!ft_strcmp(msh->cmds->token, "alias"))
g_return_code = alias(msh);
else if (!ft_strcmp(msh->cmds->token, "unalias"))
g_return_code = unalias(msh);
else
return (STDIN_FILENO);
return (STDOUT_FILENO);
return (0);
return (1);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/03/22 17:48:45 by tomoron ### ########.fr */
/* Updated: 2024/03/23 17:13:22 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -69,6 +69,7 @@ void exec_commands(t_msh *msh)
{
int cmd_count;
int i;
int status;
i = -1;
if (!msh->cmds)
@ -80,9 +81,13 @@ void exec_commands(t_msh *msh)
ft_exit(msh, 1);
while (++i < cmd_count)
exec_command(msh, i, cmd_count);
i = cmd_count;
while (--i >= 0)
waitpid(msh->pids[i], 0, 0);
i = 0;
while (i < cmd_count)
{
waitpid(msh->pids[i], &status, 0);
g_return_code = WEXITSTATUS(status);
i++;
}
i = 0;
while (i < cmd_count)
{

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */
/* Updated: 2024/03/22 13:52:29 by tomoron ### ########.fr */
/* Updated: 2024/03/23 17:51:59 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,6 +23,8 @@ void print_env_declare(t_env *env)
int check_var_name(char *name)
{
if(ft_isdigit(*name) || !*name)
return(0);
while(*name)
{
if(!ft_isalnum(*name) && *name != '_')
@ -54,7 +56,7 @@ int ft_export(t_msh *msh)
if(!name || !check_var_name(name))
{
ft_putstr_fd("minishell: export: `", 2);
ft_putstr_fd(name, 2);
ft_putstr_fd(arg, 2);
ft_putstr_fd("': not a valid identifier\n", 2);
free(name);
return(1);

View File

@ -6,13 +6,13 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/03/22 16:45:49 by tomoron ### ########.fr */
/* Updated: 2024/03/23 16:38:10 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int g_return_code = 0;
int g_return_code = 0;
char *get_prompt(t_env *env)
{

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
/* Updated: 2024/03/22 16:44:54 by tomoron ### ########.fr */
/* Updated: 2024/03/23 16:37:25 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,6 +22,7 @@
# include "fcntl.h"
# include <sys/stat.h>
# include <signal.h>
# include <stdint.h>
typedef enum e_token_type
{

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
/* Updated: 2024/03/22 17:45:02 by tomoron ### ########.fr */
/* Updated: 2024/03/23 17:28:05 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,7 +42,8 @@ void execute_command(t_msh *msh, char **cmd_args, int i)
i--;
}
free(cmd_args);
ft_exit(msh, 1);
//ft_exit(msh, 1);
ft_exit(msh, g_return_code);
}
if (msh->cmds->token)
{
@ -72,7 +73,7 @@ void child(t_msh *msh, char **cmd_args, int i)
i--;
}
free(cmd_args);
ft_exit(msh, 1);
ft_exit(msh, g_return_code);
}
void parent(t_msh *msh, int i, int cmd_count)