in et out type reparé( peut-être)
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/07 18:40:53 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/17 18:29:07 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -60,13 +60,18 @@ char **get_cmd_args(t_msh *msh)
|
||||
|
||||
void remove_command_from_msh(t_msh *msh)
|
||||
{
|
||||
t_cmd *tmp;
|
||||
|
||||
free_token(msh->tokens);
|
||||
while(msh->cmds && is_cmd_type(msh->cmds))
|
||||
msh->cmds = msh->cmds->next;
|
||||
while(msh->cmds && !is_cmd_type(msh->cmds))
|
||||
msh->cmds = msh->cmds->next;
|
||||
if(msh->cmds)
|
||||
msh->tokens = parse_command(msh->cmds->value, msh->env);
|
||||
while(msh->cmds && is_cmd_type(msh->cmds))
|
||||
msh->cmds = msh->cmds->next;
|
||||
tmp = msh->cmds;
|
||||
while(tmp && !is_cmd_type(tmp))
|
||||
tmp = tmp->next;
|
||||
if(tmp)
|
||||
msh->tokens = parse_command(tmp->value, msh->env);
|
||||
else
|
||||
msh->tokens = 0;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/15 16:54:53 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/17 18:29:30 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
void get_redirections(t_msh *msh, t_cmd *cmds)
|
||||
{
|
||||
msh->in_type = 0;
|
||||
msh->out_type = 0;
|
||||
if (first_is_in_type(cmds))
|
||||
{
|
||||
get_in_type(msh, cmds);
|
||||
@ -52,7 +54,6 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
||||
cmds = cmds->next;
|
||||
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
|
||||
exec_commands(msh);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/15 17:13:30 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/17 16:45:34 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -59,15 +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))
|
||||
if (cur_token && cur_token->cmd_type == PIPE)
|
||||
{
|
||||
ft_printf_fd(2, "%s: %d\n", cur_token->value, cur_token->cmd_type);
|
||||
cur_token = cur_token->next;
|
||||
msh->in_type = PIPE;
|
||||
return ;
|
||||
}
|
||||
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))
|
||||
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))
|
||||
{
|
||||
msh->in_type = cur_token->cmd_type;
|
||||
open_input_file(msh, &cur_token);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/03 19:29:29 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/17 14:24:31 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -27,7 +27,7 @@ char *get_prompt(t_env *env)
|
||||
res = ft_strjoin_free(res, getenv("USER"), 1);
|
||||
res = ft_strjoin_free(res, "@", 1);
|
||||
}
|
||||
res = ft_strjoin_free(res, "minishell\001\033[0m\002:\001", 1);
|
||||
res = ft_strjoin_free(res, "hell\001\033[0m\002:\001", 1);
|
||||
res = ft_strjoin_free(res, ft_get_color(80, 80, 255), 3);
|
||||
res = ft_strjoin_free(res, "\033[1m\002", 1);
|
||||
cwd = getcwd(cwd_buffer, 99);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/15 17:02:17 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/17 18:33:43 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -69,6 +69,8 @@ void get_out_type(t_msh *msh, t_cmd *cmds)
|
||||
msh->out_type = CMD;
|
||||
msh->out_fd = 0;
|
||||
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)
|
||||
{
|
||||
ft_printf_fd(2, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type);
|
||||
|
Reference in New Issue
Block a user