fix quelques trucs

This commit is contained in:
tom moron
2024-04-29 22:12:46 +02:00
parent 0bad8c3cdb
commit 992f02cded
7 changed files with 17 additions and 19 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/04/23 19:56:00 by tomoron ### ########.fr */
/* Updated: 2024/04/29 21:47:25 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,10 +14,10 @@
int cmd_is_forkable_builtin(char *cmd_token)
{
if (!ft_strcmp(cmd_token, "echo") || !ft_strcmp(cmd_token, "ret")
|| !ft_strcmp(cmd_token, "env") || !ft_strcmp(cmd_token, "exit")
|| !ft_strcmp(cmd_token, "pwd") || !ft_strcmp(cmd_token, "cd")
|| !ft_strcmp(cmd_token, "export") || !ft_strcmp(cmd_token, "unset"))
if (!ft_strcmp(cmd_token, "echo") || !ft_strcmp(cmd_token, "env")
|| !ft_strcmp(cmd_token, "exit") || !ft_strcmp(cmd_token, "pwd")
|| !ft_strcmp(cmd_token, "cd") || !ft_strcmp(cmd_token, "export")
|| !ft_strcmp(cmd_token, "unset"))
return (1);
return (0);
}
@ -48,8 +48,6 @@ int exec_builtin(t_msh *msh)
return (0);
if (!ft_strcmp(msh->tokens->value, "echo"))
g_return_code = echo(msh->tokens->next);
else if (!ft_strcmp(msh->tokens->value, "ret"))
g_return_code = ft_atoi(msh->tokens->next->value);
else if (!ft_strcmp(msh->tokens->value, "env"))
g_return_code = print_env(msh->env);
else if (!ft_strcmp(msh->tokens->value, "exit"))

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 15:30:37 by tomoron #+# #+# */
/* Updated: 2024/04/29 21:42:38 by tomoron ### ########.fr */
/* Updated: 2024/04/29 22:11:06 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,7 +42,7 @@ int echo(t_token *args)
if (!args->value[i] && i > 1)
put_nl = 0;
else
break;
break ;
args = args->next;
}
put_args(args);

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
/* Updated: 2024/04/26 15:26:41 by tomoron ### ########.fr */
/* Updated: 2024/04/29 22:06:15 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -75,6 +75,7 @@ void exec_command(t_msh *msh, int i, int cmd_count)
get_redirections(msh, msh->cmds);
if (msh->in_fd != -2)
{
msh->last_return_code = g_return_code;
g_return_code = 0;
msh->fds[i] = ft_calloc(2, sizeof(int *));
if (!msh->fds[i])
@ -121,8 +122,8 @@ void exec_commands(t_msh *msh)
if (!msh->tokens && !is_parenthesis(msh->cmds))
{
g_return_code = 0;
get_redirections(msh, msh->cmds);
g_return_code = (msh->in_fd == -1 || msh->out_fd == -1);
if (msh->in_fd > 2)
close(msh->in_fd);
if (msh->out_fd > 2)

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
/* Updated: 2024/04/26 10:49:17 by marde-vr ### ########.fr */
/* Updated: 2024/04/29 21:54:57 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,7 +39,7 @@ void get_exit_bt_return_code(t_msh *msh, int *exit_code)
else if (cur_cmd)
*exit_code = (unsigned char)ft_atoi(cur_cmd->value);
else
*exit_code = g_return_code;
*exit_code = msh->last_return_code;
}
int exit_bt(t_msh *msh)

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
/* Updated: 2024/04/25 18:53:51 by marde-vr ### ########.fr */
/* Updated: 2024/04/29 22:11:22 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,7 +35,8 @@ int print_env(t_env *env)
{
while (env)
{
ft_printf("%s=%s\n", env->name, env->value);
if (*env->value)
ft_printf("%s=%s\n", env->name, env->value);
env = env->next;
}
return (0);

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
/* Updated: 2024/04/29 11:12:35 by marde-vr ### ########.fr */
/* Updated: 2024/04/29 21:50:52 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -73,6 +73,7 @@ typedef struct s_msh
int in_fd;
int echoctl;
int out_fd;
int last_return_code;
int locked_return_code;
char *here_doc_filename;
} t_msh;

3
todo
View File

@ -1,6 +1,3 @@
- cat filenotfound -> exit # (exit avec le status 0 et pas 1)
- < filenotfound # (status code pas a 1)
- export aaa -> env # (variable aaa qui s'affiche)
- .. # (pas de command not found)
- cat Makefile | commandnotfound | cat
- cat < Makefile | rev | cat -e | rev | cat