migrated to msh struct and normed

This commit is contained in:
mdev9
2024-02-21 17:47:23 +01:00
parent d70952b7be
commit c1ed9b355d
10 changed files with 132 additions and 125 deletions

View File

@ -6,30 +6,30 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/17 02:54:36 by tomoron #+# #+# */
/* Updated: 2024/02/21 13:09:40 by marde-vr ### ########.fr */
/* Updated: 2024/02/21 17:21:27 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_cmd *handle_alias(t_cmd *cmd, t_env *env, t_alias *alias)
t_cmd *handle_alias(t_msh *msh)
{
t_cmd *res;
t_cmd *tmp;
char *alias_command;
alias_command = 0;
if (!cmd)
if (!msh->cmds)
return (0);
if (cmd->type == ARG)
alias_command = get_alias(alias, cmd->token);
if (msh->cmds->type == ARG)
alias_command = get_alias(msh->aliases, msh->cmds->token);
if (!alias_command)
return (cmd);
res = parse_command(alias_command, env);
return (msh->cmds);
res = parse_command(alias_command, msh->env);
tmp = res;
while (tmp->next)
tmp = tmp->next;
tmp->next = cmd->next;
free(cmd);
tmp->next = msh->cmds->next;
free(msh->cmds);
return (res);
}