diff --git a/Makefile b/Makefile index 24cc128..c1ffe4f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: marde-vr +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/07/28 00:35:01 by tomoron #+# #+# # -# Updated: 2024/04/15 16:41:54 by tomoron ### ########.fr # +# Updated: 2024/04/15 18:58:21 by tomoron ### ########.fr # # # # **************************************************************************** # @@ -57,7 +57,7 @@ all: $(NAME) : $(LIBFT) $(OBJS) @$(CC) $(FLAGS) $(OBJS) $(LIBFT) -lreadline -o $(NAME) @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 'if [ "$$USER" == marde-vr ];then exit;fi;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): @echo compiling libft... diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index 8f53371..4353f0e 100755 --- a/srcs/exec_bonus.c +++ b/srcs/exec_bonus.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ -/* Updated: 2024/04/13 16:22:58 by babonnet ### ########.fr */ +/* Updated: 2024/04/15 16:54:53 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,8 +53,8 @@ void exec_command_bonus(t_msh *msh, char *cmd_str) msh->tokens = parse_command(cmds->value, msh->env); msh->cmds = cmds; get_redirections(msh, cmds); - print_msh_struct(msh); // debug - print_parsed_token(msh->tokens); // debug + //print_msh_struct(msh); // debug + //print_parsed_token(msh->tokens); // debug exec_commands(msh); msh->in_fd = 0; msh->out_fd = 0; @@ -71,13 +71,12 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count) if (i != cmd_count - 1) { - printf("pipe\n"); if (pipe(msh->fds[i]) == -1) { perror("minishell: pipe"); ft_exit(msh, 1); } - ft_printf_fd(2, "msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); + ft_printf_fd(2, "pipe: msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); } pid = fork(); if (pid == -1) @@ -160,8 +159,8 @@ void exec_commands(t_msh *msh) i = 0; 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); exec_command(msh, i, cmd_count); free(msh->fds[i]); i++; diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index 7b79faa..3c446f8 100755 --- a/srcs/input_redirections.c +++ b/srcs/input_redirections.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 15:58:27 by babonnet ### ########.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; cur_token = tokens; + //if (cur_token->cmd_type == PIPE) 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; + } + 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)) { msh->in_type = cur_token->cmd_type; diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 6b88955..c028f84 100755 --- a/srcs/output_redirections.c +++ b/srcs/output_redirections.c @@ -6,11 +6,12 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 21:25:23 by babonnet ### ########.fr */ +/* Updated: 2024/04/15 17:02:17 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +#include void redirect_output(t_msh *msh, int i) { @@ -22,10 +23,19 @@ void redirect_output(t_msh *msh, int i) } else { - ft_printf_fd(0, "redirecting pipe output\n"); - ft_printf_fd(0, "output of cmd %d: 1 -> %d\n", i, msh->fds[i - 1][1]); + ft_printf_fd(2, "redirecting pipe output\n"); + ft_printf_fd(2, "%p\n", msh->fds[i]); + //ft_printf_fd(2, "output of cmd %d: 1 -> %d\n", i, msh->fds[i - 1][1]); + ft_printf_fd(2, "yes\n"); + //sleep(1); if (dup2(msh->fds[i][1], 1) < 0) - ft_exit(msh, 1); + { + perror("dup2"); + ft_printf_fd(2, "exiting\n"); + //ft_exit(msh, 1); + } + ft_printf_fd(2,"help pls\n"); + fflush(stdout); // Flush stdout } } @@ -60,7 +70,12 @@ void get_out_type(t_msh *msh, t_cmd *cmds) msh->out_fd = 0; cur_cmd = cmds; 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; + } + 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) msh->out_type = 0; else if(cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) diff --git a/srcs/pipe.c b/srcs/pipe.c index 32494b4..755b11a 100755 --- a/srcs/pipe.c +++ b/srcs/pipe.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 15:39:50 by babonnet ### ########.fr */ +/* Updated: 2024/04/14 11:34:47 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,6 +56,7 @@ void child(t_msh *msh, char **cmd_args, int i) if (msh->out_type == PIPE || msh->out_type == RED_O || msh->out_type == RED_O_APP) redirect_output(msh, i); + ft_printf_fd(2, "closing fds\n"); close_pipe_fds(msh, i); execute_command(msh, cmd_args); close(0); diff --git a/srcs/signal_handler.c b/srcs/signal_handler.c index 8e766b9..a976d86 100755 --- a/srcs/signal_handler.c +++ b/srcs/signal_handler.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */ -/* Updated: 2024/04/03 19:23:33 by tomoron ### ########.fr */ +/* Updated: 2024/04/14 11:41:06 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,7 +57,7 @@ int set_echoctl(int value) { struct termios t_p; - ft_printf("echoctl value : %d\n",value); + //ft_printf("echoctl value : %d\n",value); if (tcgetattr(1, &t_p)) { ft_printf_fd(2, "minishell: an error occured while getting the local fl\ diff --git a/srcs/utils.c b/srcs/utils.c index e80d1a3..0d87989 100755 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */ -/* Updated: 2024/04/03 15:46:38 by tomoron ### ########.fr */ +/* Updated: 2024/04/14 11:29:02 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ void free_msh(t_msh *msh) void ft_exit(t_msh *msh, int exit_code) { + ft_printf("exiting"); free_msh(msh); exit(exit_code); } diff --git a/srcs/vim b/srcs/vim new file mode 100644 index 0000000..397db75 --- /dev/null +++ b/srcs/vim @@ -0,0 +1 @@ +: