fixed broken redirects from norming, working on broken echo command

This commit is contained in:
mdev9
2024-03-26 09:22:12 +01:00
parent 0fb72c0c2c
commit d767ea3f10
3 changed files with 13 additions and 12 deletions

View File

@ -6,7 +6,7 @@
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ # # By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# # # Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
# Updated: 2024/03/25 12:33:26 by tomoron ### ########.fr # # Updated: 2024/03/26 09:08:03 by marde-vr ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -21,10 +21,11 @@ SRCS_RAW = main.c\
pwd.c\ pwd.c\
parsing.c\ parsing.c\
debug.c\ debug.c\
env_to_char_tab.c\ env_utils.c\
parsing_var.c\ parsing_var.c\
path.c\ path.c\
here_doc.c\ here_doc.c\
here_doc_utils.c\
export.c\ export.c\
input_redirections.c\ input_redirections.c\
output_redirections.c\ output_redirections.c\

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
/* Updated: 2024/03/26 09:10:12 by marde-vr ### ########.fr */ /* Updated: 2024/03/26 09:19:40 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -65,8 +65,8 @@ char **get_cmd_args(t_msh *msh)
if (!cmd_args || !msh->fds) if (!cmd_args || !msh->fds)
ft_exit(msh, 1); ft_exit(msh, 1);
cur_cmd = msh->cmds; cur_cmd = msh->cmds;
i = -1; i = 0;
while (++i < args_count) while (i < args_count)
{ {
if (cur_cmd->type == ARG) if (cur_cmd->type == ARG)
{ {
@ -74,6 +74,7 @@ char **get_cmd_args(t_msh *msh)
cmd_args[i] = remove_path(cur_cmd->token); cmd_args[i] = remove_path(cur_cmd->token);
else else
cmd_args[i] = cur_cmd->token; cmd_args[i] = cur_cmd->token;
i++;
} }
else else
cur_cmd = cur_cmd->next; cur_cmd = cur_cmd->next;

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */ /* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
/* Updated: 2024/03/26 08:59:44 by marde-vr ### ########.fr */ /* Updated: 2024/03/26 09:14:22 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,18 +20,17 @@ void numeric_arg_err(char *arg, int *exit_code)
*exit_code = 2; *exit_code = 2;
} }
void get_exit_bt_return_code(t_msh *msh) void get_exit_bt_return_code(t_msh *msh, int *exit_code)
{ {
t_cmd *cur_cmd; t_cmd *cur_cmd;
int exit_code;
cur_cmd = msh->cmds->next; cur_cmd = msh->cmds->next;
if (cur_cmd && cur_cmd->type == ARG && !ft_strisnbr(cur_cmd->token)) if (cur_cmd && cur_cmd->type == ARG && !ft_strisnbr(cur_cmd->token))
numeric_arg_err(cur_cmd->token, &exit_code); numeric_arg_err(cur_cmd->token, exit_code);
else if (cur_cmd && cur_cmd->type == ARG) else if (cur_cmd && cur_cmd->type == ARG)
exit_code = (unsigned char)ft_atoi(cur_cmd->token); *exit_code = (unsigned char)ft_atoi(cur_cmd->token);
else else
exit_code = g_return_code; *exit_code = g_return_code;
} }
void exit_bt(t_msh *msh) void exit_bt(t_msh *msh)
@ -50,7 +49,7 @@ void exit_bt(t_msh *msh)
} }
else else
{ {
get_exit_bt_return_code(msh); get_exit_bt_return_code(msh, &exit_code);
if (msh->fds) if (msh->fds)
{ {
cmd_count = get_cmd_count(msh->cmds); cmd_count = get_cmd_count(msh->cmds);