alias modifiable
This commit is contained in:
@ -6,13 +6,13 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/16 23:16:07 by marde-vr #+# #+# */
|
/* 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:25:24 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int alias(t_cmd *args, t_alias *aliases)
|
int alias(t_cmd *args, t_alias **aliases)
|
||||||
{
|
{
|
||||||
(void)args;
|
(void)args;
|
||||||
(void)aliases;
|
(void)aliases;
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
|
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/02/17 04:18:31 by tomoron ### ########.fr */
|
/* Updated: 2024/02/18 16:22:58 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int exec_builtin(t_cmd *parsed_cmd, t_env *env, t_alias *aliases)
|
int exec_builtin(t_cmd *parsed_cmd, t_env *env, t_alias **aliases)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!ft_strcmp(parsed_cmd->token, "echo"))
|
if (!ft_strcmp(parsed_cmd->token, "echo"))
|
||||||
@ -22,7 +22,7 @@ int exec_builtin(t_cmd *parsed_cmd, t_env *env, t_alias *aliases)
|
|||||||
else if (!ft_strcmp(parsed_cmd->token, "env"))
|
else if (!ft_strcmp(parsed_cmd->token, "env"))
|
||||||
g_return_code = print_env(env);
|
g_return_code = print_env(env);
|
||||||
else if (!ft_strcmp(parsed_cmd->token, "exit"))
|
else if (!ft_strcmp(parsed_cmd->token, "exit"))
|
||||||
exit_bt(parsed_cmd, env, aliases);
|
exit_bt(parsed_cmd, env, *aliases);
|
||||||
else if (!ft_strcmp(parsed_cmd->token, "pwd"))
|
else if (!ft_strcmp(parsed_cmd->token, "pwd"))
|
||||||
g_return_code = pwd();
|
g_return_code = pwd();
|
||||||
else if (!ft_strcmp(parsed_cmd->token, "cd"))
|
else if (!ft_strcmp(parsed_cmd->token, "cd"))
|
||||||
@ -134,7 +134,7 @@ void get_cmd_path(t_cmd *cmd, t_env *env)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_command(t_cmd *parsed_cmd, t_env *env, t_alias *aliases)
|
void exec_command(t_cmd *parsed_cmd, t_env *env, t_alias **aliases)
|
||||||
{
|
{
|
||||||
t_cmd *cur_cmd;
|
t_cmd *cur_cmd;
|
||||||
int args_count;
|
int args_count;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/02/18 13:50:32 by tomoron ### ########.fr */
|
/* Updated: 2024/02/18 16:19:12 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ int main(int argc, char **argv, char **envp)
|
|||||||
free(prompt);
|
free(prompt);
|
||||||
add_history(command);
|
add_history(command);
|
||||||
parsed_cmd = parse_command(command, env);
|
parsed_cmd = parse_command(command, env);
|
||||||
print_parsed_cmd(parsed_cmd);//debug
|
//print_parsed_cmd(parsed_cmd);//debug
|
||||||
parsed_cmd = handle_alias(parsed_cmd, env, aliases);
|
parsed_cmd = handle_alias(parsed_cmd, env, aliases);
|
||||||
free(command);
|
free(command);
|
||||||
print_parsed_cmd(parsed_cmd);//debug
|
//print_parsed_cmd(parsed_cmd);//debug
|
||||||
exec_command(parsed_cmd, env, aliases);
|
exec_command(parsed_cmd, env, &aliases);
|
||||||
free_cmd(parsed_cmd);
|
free_cmd(parsed_cmd);
|
||||||
}
|
}
|
||||||
rl_clear_history();
|
rl_clear_history();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/02/18 13:19:19 by tomoron ### ########.fr */
|
/* Updated: 2024/02/18 16:26:27 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ extern int g_return_code;
|
|||||||
|
|
||||||
t_cmd *cmd_add_back(t_cmd *res, char *token, t_token_type type);
|
t_cmd *cmd_add_back(t_cmd *res, char *token, t_token_type type);
|
||||||
void free_cmd(t_cmd *cmd);
|
void free_cmd(t_cmd *cmd);
|
||||||
void exec_command(t_cmd *cmd, t_env *env, t_alias *alias);
|
void exec_command(t_cmd *cmd, t_env *env, t_alias **alias);
|
||||||
int echo(t_cmd *args);
|
int echo(t_cmd *args);
|
||||||
void exit_bt(t_cmd *args, t_env *env, t_alias *aliases);
|
void exit_bt(t_cmd *args, t_env *env, t_alias *aliases);
|
||||||
t_env *env_add_back(t_env *env, char *name, char *value);
|
t_env *env_add_back(t_env *env, char *name, char *value);
|
||||||
@ -75,7 +75,7 @@ char **env_to_char_tab(t_env *env);
|
|||||||
void handle_minishellrc(t_env *env, t_alias *aliases);
|
void handle_minishellrc(t_env *env, t_alias *aliases);
|
||||||
t_cmd *handle_alias(t_cmd *cmd, t_env *env, t_alias *alias);
|
t_cmd *handle_alias(t_cmd *cmd, t_env *env, t_alias *alias);
|
||||||
int cd(t_cmd *args);
|
int cd(t_cmd *args);
|
||||||
int alias(t_cmd *args, t_alias *aliases);
|
int alias(t_cmd *args, t_alias **aliases);
|
||||||
void free_alias(t_alias *alias);
|
void free_alias(t_alias *alias);
|
||||||
char *ft_get_alias(t_alias *alias, char *var_name);
|
char *ft_get_alias(t_alias *alias, char *var_name);
|
||||||
t_alias *alias_add_back(t_alias *alias, char *name, char *value);
|
t_alias *alias_add_back(t_alias *alias, char *name, char *value);
|
||||||
|
Reference in New Issue
Block a user