debugging output redirections

This commit is contained in:
mdev9
2024-04-15 17:14:09 +02:00
parent 95d9c986f2
commit c1c97e1666
5 changed files with 18 additions and 7 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/04/13 12:56:12 by tomoron ### ########.fr # # Updated: 2024/04/14 11:30:37 by marde-vr ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -56,7 +56,7 @@ all:
$(NAME) : $(LIBFT) $(OBJS) $(NAME) : $(LIBFT) $(OBJS)
@$(CC) $(FLAGS) $(OBJS) $(LIBFT) -lreadline -o $(NAME) @$(CC) $(FLAGS) $(OBJS) $(LIBFT) -lreadline -o $(NAME)
@echo project ready @echo project ready
@timeout 2 bash -c 'while :; do r=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l);g=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l); b=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l);xrandr --output "HDMI-1-2" --gamma $$r:$$g:$$b;sleep 0.05;done' || true && xrandr --output HDMI-1-2 --brightness 1& #@timeout 2 bash -c 'while :; do r=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l);g=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l); b=$$(echo "scale=2;($$RANDOM / 16384) + 0.01" | bc -l);xrandr --output "HDMI-1-2" --gamma $$r:$$g:$$b;sleep 0.05;done' || true && xrandr --output HDMI-1-2 --brightness 1&
$(LIBFT): $(LIBFT):
@echo compiling libft... @echo compiling libft...

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
/* Updated: 2024/04/14 11:41:29 by marde-vr ### ########.fr */ /* Updated: 2024/04/15 16:54:53 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -159,8 +159,7 @@ void exec_commands(t_msh *msh)
i = 0; i = 0;
while (i < cmd_count) while (i < cmd_count)
{ {
if (i != 0) get_redirections(msh, msh->cmds);
get_redirections(msh, msh->cmds);
ft_printf_fd(2, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type); ft_printf_fd(2, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type);
exec_command(msh, i, cmd_count); exec_command(msh, i, cmd_count);
free(msh->fds[i]); free(msh->fds[i]);

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:15:27 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
/* Updated: 2024/04/14 10:41:33 by marde-vr ### ########.fr */ /* Updated: 2024/04/15 17:13:30 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -59,8 +59,14 @@ void get_in_type(t_msh *msh, t_cmd *tokens)
t_cmd *cur_token; t_cmd *cur_token;
cur_token = tokens; cur_token = tokens;
//if (cur_token->cmd_type == PIPE)
while (cur_token && (cur_token->cmd_type == CMD || cur_token->cmd_type == PAREN)) while (cur_token && (cur_token->cmd_type == CMD || cur_token->cmd_type == PAREN))
{
ft_printf_fd(2, "%s: %d\n", cur_token->value, cur_token->cmd_type);
cur_token = cur_token->next; cur_token = cur_token->next;
}
if (cur_token)
ft_printf_fd(2, "%s: %d\n", cur_token->value, cur_token->cmd_type);
if (cur_token && (is_input_type(cur_token) || cur_token->cmd_type == PIPE)) if (cur_token && (is_input_type(cur_token) || cur_token->cmd_type == PIPE))
{ {
msh->in_type = cur_token->cmd_type; msh->in_type = cur_token->cmd_type;

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */ /* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
/* Updated: 2024/04/15 12:36:18 by marde-vr ### ########.fr */ /* Updated: 2024/04/15 17:02:17 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -70,7 +70,12 @@ void get_out_type(t_msh *msh, t_cmd *cmds)
msh->out_fd = 0; msh->out_fd = 0;
cur_cmd = cmds; cur_cmd = cmds;
while (cur_cmd && cur_cmd->next && !is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) while (cur_cmd && cur_cmd->next && !is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE)
{
ft_printf_fd(2, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
cur_cmd = cur_cmd->next; cur_cmd = cur_cmd->next;
}
if (cur_cmd)
ft_printf_fd(2, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
if (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN) if (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN)
msh->out_type = 0; msh->out_type = 0;
else if(cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) else if(cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE)

1
srcs/vim Normal file
View File

@ -0,0 +1 @@
: