command work good
This commit is contained in:
parent
830a977272
commit
14e7abeedb
4
main.c
4
main.c
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/06 13:27:11 by apommier #+# #+# */
|
||||
/* Updated: 2022/03/09 11:16:07 by apommier ### ########.fr */
|
||||
/* Updated: 2022/03/09 11:37:23 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,7 +38,7 @@ void print_prompt(char **path)
|
||||
add_history(input);
|
||||
cmd = set_cmd(input, path);
|
||||
if (cmd)
|
||||
execute(cmd);
|
||||
execute(cmd, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ typedef struct s_command {
|
||||
int main();//int ac, char **av, char **path);
|
||||
|
||||
//pipe.c
|
||||
void execute(t_cmd *cmd);
|
||||
void execute(t_cmd *cmd, char **env);
|
||||
|
||||
//set_cmd.c
|
||||
t_cmd *set_cmd(char *input, char **path);
|
||||
|
||||
13
pipe.c
13
pipe.c
@ -6,13 +6,13 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/07 11:13:32 by apommier #+# #+# */
|
||||
/* Updated: 2022/03/08 20:38:11 by apommier ### ########.fr */
|
||||
/* Updated: 2022/03/09 11:37:06 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void execute(t_cmd *cmd)
|
||||
void execute(t_cmd *cmd, char **env)
|
||||
{
|
||||
//save in/out
|
||||
int ret;
|
||||
@ -23,11 +23,10 @@ void execute(t_cmd *cmd)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
//set the initial input
|
||||
if (cmd->current_s_cmd->infile)//redirection
|
||||
if (cmd->current_s_cmd->infile)//set the initial input
|
||||
fdin = open(cmd->current_s_cmd->infile, O_RDONLY);
|
||||
else if (cmd->infile)//?
|
||||
fdin = open(cmd->infile, O_RDONLY);
|
||||
//else if (cmd->infile)
|
||||
// fdin = open(cmd->infile, O_RDONLY);
|
||||
else
|
||||
fdin=dup(tmpin);
|
||||
while( i < cmd->nb_s_cmd)
|
||||
@ -71,7 +70,7 @@ void execute(t_cmd *cmd)
|
||||
ret=fork();
|
||||
if(ret==0)
|
||||
{
|
||||
execve(cmd->current_s_cmd->cmd, cmd->current_s_cmd->args, cmd->path);
|
||||
execve(cmd->current_s_cmd->cmd, cmd->current_s_cmd->args, env);//cmd->path);
|
||||
//_exit(1);
|
||||
}
|
||||
i++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user