aliases done

This commit is contained in:
mdev9
2024-02-18 17:02:38 +01:00
parent cec4e7a3a3
commit e126456b49
4 changed files with 40 additions and 10 deletions

View File

@ -6,16 +6,48 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/16 23:16:07 by marde-vr #+# #+# */
/* Updated: 2024/02/17 04:22:39 by tomoron ### ########.fr */
/* Updated: 2024/02/18 16:59:56 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
char *get_alias_name(t_cmd *arg)
{
int i = 0;
while (arg->token[i] != '=')
i++;
i++;
char *res;
res = ft_strdup("");
ft_strlcpy(res, arg->token, i);
//ft_printf("name: %s\n", res);
return (res);
}
char *get_alias_value(t_cmd *arg)
{
int i = 0;
while (arg->token[i] != '=')
i++;
i++;
char *res;
res = arg->token + i;
//ft_printf("value: %s\n", res);
return (res);
}
int alias(t_cmd *args, t_alias *aliases)
{
(void)args;
(void)aliases;
return(0);
//GLHF marijn
if (ft_strchr(args->next->token, '='))
{
char *name = get_alias_name(args->next);
char *value = get_alias_value(args->next);
aliases = alias_add_back(aliases, name, value);
}
else
{
//nothin
}
return(0);
}

View File

@ -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:34:24 by tomoron ### ########.fr */
/* Updated: 2024/02/18 16:31:52 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,5 +53,3 @@ char *ft_get_alias(t_alias *alias, char *name)
}
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/02/18 13:50:32 by tomoron ### ########.fr */
/* Updated: 2024/02/18 17:00:21 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -95,7 +95,7 @@ int main(int argc, char **argv, char **envp)
print_parsed_cmd(parsed_cmd);//debug
parsed_cmd = handle_alias(parsed_cmd, env, aliases);
free(command);
print_parsed_cmd(parsed_cmd);//debug
//print_parsed_cmd(parsed_cmd);//debug
exec_command(parsed_cmd, env, aliases);
free_cmd(parsed_cmd);
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/16 17:40:16 by marde-vr #+# #+# */
/* Updated: 2024/02/17 04:30:14 by tomoron ### ########.fr */
/* Updated: 2024/02/18 16:39:02 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */