merge
This commit is contained in:
2
Makefile
2
Makefile
@ -6,7 +6,7 @@
|
||||
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
||||
# Updated: 2024/04/18 23:04:47 by marde-vr ### ########.fr #
|
||||
# Updated: 2024/04/18 23:06:00 by marde-vr ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/07 17:14:57 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:48 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/16 21:02:54 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:04 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:50 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/17 18:29:07 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:51 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/07 17:27:45 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:51 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/07 15:30:37 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 00:44:56 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:52 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/16 13:30:18 by tomoron #+# #+# */
|
||||
/* Updated: 2024/03/26 08:49:12 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:52 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/03 17:21:57 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:52 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/18 18:29:10 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/18 21:06:26 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -36,12 +36,12 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
||||
t_cmd *tmp;
|
||||
|
||||
cmds = parsing_bonus(cmd_str);
|
||||
print_parsed_cmd(cmds); // debug
|
||||
//print_parsed_cmd(cmds); // debug
|
||||
tmp = check_cmds_syntax(cmds);
|
||||
if (tmp)
|
||||
{
|
||||
print_syntax_error_bonus(tmp);
|
||||
printf("error\n"); // debug
|
||||
//printf("error\n"); // debug
|
||||
free_cmd(cmds);
|
||||
return ;
|
||||
}
|
||||
@ -72,13 +72,13 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
|
||||
|
||||
if (i != cmd_count - 1)
|
||||
{
|
||||
fprintf(stderr, "piping %d", i);
|
||||
//fprintf(stderr, "piping %d", i);
|
||||
if (pipe(msh->fds[i]) == -1)
|
||||
{
|
||||
perror("minishell: pipe");
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
fprintf(stderr, "pipe: msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]);
|
||||
//fprintf(stderr, "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)
|
||||
@ -99,7 +99,7 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
|
||||
|
||||
void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
{
|
||||
g_return_code = 0;
|
||||
//g_return_code = 0;
|
||||
msh->fds[i] = ft_calloc(2, sizeof(int *));
|
||||
if (!msh->fds[i])
|
||||
ft_exit(msh, 1);
|
||||
@ -153,7 +153,7 @@ void exec_commands(t_msh *msh)
|
||||
if (!msh->tokens)
|
||||
return ;
|
||||
cmd_count = get_cmd_count(msh->cmds);
|
||||
printf("cmd_count : %d\n", cmd_count);
|
||||
//printf("cmd_count : %d\n", cmd_count);
|
||||
msh->fds = ft_calloc(cmd_count, sizeof(int **));
|
||||
msh->pids = ft_calloc(cmd_count, sizeof(int *));
|
||||
if (!msh->pids || !msh->fds)
|
||||
@ -162,7 +162,7 @@ void exec_commands(t_msh *msh)
|
||||
while (i < cmd_count)
|
||||
{
|
||||
get_redirections(msh, msh->cmds);
|
||||
fprintf(stderr, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type);
|
||||
//fprintf(stderr, "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++;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/03 15:44:06 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:53 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/03 15:45:32 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:53 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:53 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/26 09:06:51 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/03/26 09:07:42 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:54 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 18:25:20 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:54 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,15 +16,15 @@ void redirect_input(t_msh *msh, int i)
|
||||
{
|
||||
if (msh->in_type != PIPE)
|
||||
{
|
||||
fprintf(stderr, "redirecting input\n");
|
||||
//fprintf(stderr, "redirecting input\n");
|
||||
if (dup2(msh->in_fd, 0) < 0)
|
||||
ft_exit(msh, 1);
|
||||
close(msh->in_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "redirecting pipe input\n");
|
||||
fprintf(stderr, "input of cmd %d: %d -> 0\n", i, msh->fds[i - 1][0]);
|
||||
//fprintf(stderr, "redirecting pipe input\n");
|
||||
//fprintf(stderr, "input of cmd %d: %d -> 0\n", i, msh->fds[i - 1][0]);
|
||||
if (dup2(msh->fds[i - 1][0], 0) < 0)
|
||||
{
|
||||
perror("dup2"); //debug
|
||||
@ -67,7 +67,8 @@ void get_in_type(t_msh *msh, t_cmd *tokens)
|
||||
msh->in_type = PIPE;
|
||||
return ;
|
||||
}
|
||||
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))
|
||||
cur_token = cur_token->next;
|
||||
if (cur_token && is_input_type(cur_token))
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 17:31:53 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:54 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
||||
/* Updated: 2024/03/29 14:30:00 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:55 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
||||
/* Updated: 2024/02/17 04:33:17 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:55 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 00:44:16 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:56 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/17 14:24:31 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:57:00 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -96,6 +96,9 @@ int main(int argc, char **argv, char **envp)
|
||||
char *commands;
|
||||
char *prompt;
|
||||
t_msh *msh;
|
||||
char *commands;
|
||||
char *prompt;
|
||||
t_msh *msh;
|
||||
|
||||
commands = (char *)1;
|
||||
init_minishell(&msh, argc, argv, envp);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:57 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,18 +17,18 @@ void redirect_output(t_msh *msh, int i)
|
||||
{
|
||||
if (msh->out_type != PIPE)
|
||||
{
|
||||
fprintf(stderr, "redirecting output\n");
|
||||
//fprintf(stderr, "redirecting output\n");
|
||||
if (dup2(msh->out_fd, 1) < 0)
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "redirecting pipe output\n");
|
||||
//fprintf(stderr, "redirecting pipe output\n");
|
||||
//sleep(1);
|
||||
if (dup2(msh->fds[i][1], 1) < 0)
|
||||
{
|
||||
perror("dup2");
|
||||
fprintf(stderr, "exiting\n");
|
||||
//fprintf(stderr, "exiting\n");
|
||||
//ft_exit(msh, 1);
|
||||
}
|
||||
}
|
||||
@ -66,16 +66,18 @@ void get_out_type(t_msh *msh, t_cmd *cmds)
|
||||
cur_cmd = cmds;
|
||||
while (cur_cmd && !is_cmd_type(cur_cmd))
|
||||
cur_cmd = cur_cmd->next;
|
||||
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)
|
||||
{
|
||||
fprintf(stderr, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
|
||||
//fprintf(stderr, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
|
||||
cur_cmd = cur_cmd->next;
|
||||
}
|
||||
if (cur_cmd)
|
||||
fprintf(stderr, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
|
||||
//if (cur_cmd)
|
||||
//fprintf(stderr, "%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)
|
||||
else if (cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd)
|
||||
&& cur_cmd->cmd_type != PIPE)
|
||||
{
|
||||
msh->out_type = cur_cmd->cmd_type;
|
||||
filename = parse_command(cur_cmd->value, msh->env);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/15 15:56:17 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:57 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "minishell.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:57 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */
|
||||
/* Updated: 2024/03/28 14:10:02 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:58 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:58 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
26
srcs/pipe.c
26
srcs/pipe.c
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:58 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,23 +18,23 @@ void close_pipe_fds(t_msh *msh, int i)
|
||||
{
|
||||
if (msh->fds[i - 1][0] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][0]);
|
||||
//fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][0]);
|
||||
close(msh->fds[i - 1][0]);
|
||||
}
|
||||
if (msh->fds[i - 1][1] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][1]);
|
||||
//fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][1]);
|
||||
close(msh->fds[i - 1][1]);
|
||||
}
|
||||
}
|
||||
if (msh->fds[i][0] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in child\n", msh->fds[i][0]);
|
||||
//fprintf(stderr, "closing fd %d in child\n", msh->fds[i][0]);
|
||||
close(msh->fds[i][0]);
|
||||
}
|
||||
if (msh->fds[i][1] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in child\n", msh->fds[i][1]);
|
||||
//fprintf(stderr, "closing fd %d in child\n", msh->fds[i][1]);
|
||||
close(msh->fds[i][1]);
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,7 @@ void execute_command(t_msh *msh, char **cmd_args)
|
||||
env = env_to_char_tab(msh->env);
|
||||
if (env)
|
||||
{
|
||||
fprintf(stderr, "execveing %s\n", msh->tokens->value);
|
||||
//fprintf(stderr, "execveing %s\n", msh->tokens->value);
|
||||
execve(msh->tokens->value, cmd_args, env);
|
||||
}
|
||||
ft_free_str_arr(env);
|
||||
@ -71,7 +71,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);
|
||||
fprintf(stderr, "closing fds\n");
|
||||
//fprintf(stderr, "closing fds\n");
|
||||
close_pipe_fds(msh, i);
|
||||
execute_command(msh, cmd_args);
|
||||
close(0);
|
||||
@ -89,12 +89,12 @@ void parent(t_msh *msh, int i, int cmd_count)
|
||||
{
|
||||
if (msh->fds[i - 1][0] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][0]);
|
||||
//fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][0]);
|
||||
close(msh->fds[i - 1][0]);
|
||||
}
|
||||
if (msh->fds[i - 1][1] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][1]);
|
||||
//fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][1]);
|
||||
close(msh->fds[i - 1][1]);
|
||||
}
|
||||
}
|
||||
@ -102,23 +102,23 @@ void parent(t_msh *msh, int i, int cmd_count)
|
||||
{
|
||||
if (msh->fds[i][0] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][0]);
|
||||
//fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][0]);
|
||||
close(msh->fds[i][0]);
|
||||
}
|
||||
if (msh->fds[i][1] > 2)
|
||||
{
|
||||
fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][1]);
|
||||
//fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][1]);
|
||||
close(msh->fds[i][1]);
|
||||
}
|
||||
}
|
||||
if (msh->in_fd > 2)
|
||||
{
|
||||
fprintf(stderr, "closing in_fd %d in parent\n", msh->in_fd);
|
||||
//fprintf(stderr, "closing in_fd %d in parent\n", msh->in_fd);
|
||||
close(msh->in_fd);
|
||||
}
|
||||
if (msh->out_fd > 2)
|
||||
{
|
||||
fprintf(stderr, "closing in_fd %d in parent\n", msh->out_fd);
|
||||
//fprintf(stderr, "closing in_fd %d in parent\n", msh->out_fd);
|
||||
close(msh->out_fd);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 18:31:21 by tomoron #+# #+# */
|
||||
/* Updated: 2024/02/21 12:47:39 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:59 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "minishell.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:57:35 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -60,21 +60,21 @@ int set_echoctl(int value)
|
||||
//ft_printf("echoctl value : %d\n",value);
|
||||
if (tcgetattr(1, &t_p))
|
||||
{
|
||||
fprintf(stderr, "minishell: an error occured while getting the local fl\
|
||||
ags\n");
|
||||
//fprintf(stderr, "minishell: an error occured while getting the local fl\
|
||||
//ags\n");
|
||||
return (1);
|
||||
}
|
||||
if (((t_p.c_lflag & ECHOCTL) != 0) == value)
|
||||
return (0);
|
||||
ft_printf("change\n");
|
||||
//ft_printf("change\n");
|
||||
if (value)
|
||||
t_p.c_lflag = t_p.c_lflag | ECHOCTL;
|
||||
else
|
||||
t_p.c_lflag = t_p.c_lflag & (~ECHOCTL);
|
||||
if (tcsetattr(1, TCSANOW, &t_p))
|
||||
{
|
||||
fprintf(stderr, "minishell: an error occured while setting the local fl\
|
||||
ags\n");
|
||||
//fprintf(stderr, "minishell: an error occured while setting the local fl\
|
||||
//ags\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/17 09:12:33 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/17 10:42:39 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:49:00 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,7 +21,7 @@ int wildcard_cmp(char *s1, char *s2, char *order)
|
||||
while (*s2 && !ft_isalnum(*s2))
|
||||
s2++;
|
||||
if (*s1 != *s2)
|
||||
return ((ft_strchr(order, *s2) - order) - (ft_strchr(order, *s1)\
|
||||
return ((ft_strchr(order, *s2) - order) - (ft_strchr(order, *s1)
|
||||
- order));
|
||||
s1++;
|
||||
s2++;
|
||||
@ -42,7 +42,8 @@ void sort_wildcards_token(t_token *list)
|
||||
list = start;
|
||||
while (list->next)
|
||||
{
|
||||
if(wildcard_cmp(list->value, list->next->value, "zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA9876543210") > 0)
|
||||
if (wildcard_cmp(list->value, list->next->value,
|
||||
"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA9876543210") > 0)
|
||||
{
|
||||
swap = list->value;
|
||||
list->value = list->next->value;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:49:01 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -26,7 +26,7 @@ void free_msh(t_msh *msh)
|
||||
|
||||
void ft_exit(t_msh *msh, int exit_code)
|
||||
{
|
||||
ft_printf("exiting");
|
||||
//ft_printf("exiting");
|
||||
free_msh(msh);
|
||||
exit(exit_code);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 17:19:27 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/02 17:16:06 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:49:00 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/15 12:53:29 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/17 10:16:33 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/18 20:48:39 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "minishell.h"
|
||||
@ -19,7 +19,8 @@ int filename_corresponds(char *wildcard, char *value)
|
||||
{
|
||||
if (*wildcard == '*')
|
||||
{
|
||||
while(*wildcard && *value && *value != wildcard[1] && *wildcard != wildcard[1])
|
||||
while (*wildcard && *value && *value != wildcard[1]
|
||||
&& *wildcard != wildcard[1])
|
||||
value++;
|
||||
wildcard++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user