From: Dominik Kaiser Date: Thu, 17 Oct 2024 15:19:48 +0000 (+0200) Subject: Add path handling X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=a3b571e8549f7f7b5a6ca2da449cc5d3aefa9084;p=42%2Fminishell.git Add path handling --- diff --git a/Makefile b/Makefile index 283db1a..3ae1359 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ HEADERS = -I include -I $(LIB_DIR)/libft VPATH := src SRC := main.c debug_tools.c init.c signal_handling.c repl.c new_token.c \ free_token.c new_node.c free_node.c tokenizer.c parser.c \ - parse_cmd.c collect_redirs.c print_ast.c interpreter.c env.c + parse_cmd.c collect_redirs.c print_ast.c interpreter.c env.c \ + get_cmd_path.c OBJ_DIR := _obj OBJ := $(addprefix $(OBJ_DIR)/, $(SRC:%.c=%.o)) diff --git a/include/env.h b/include/env.h index ee01181..f22ebdd 100644 --- a/include/env.h +++ b/include/env.h @@ -6,7 +6,7 @@ /* By: chuhlig +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/08 16:53:39 by dkaiser #+# #+# */ -/* Updated: 2024/10/17 15:59:59 by dkaiser ### ########.fr */ +/* Updated: 2024/10/17 17:01:27 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,6 @@ typedef struct s_env struct s_env *next; } t_env; -void getenvlst(t_env **env, char **en); -void free_envlst(t_env **env); -char *env_get(t_env *env, char *name); +void getenvlst(t_env **env, char **en); +void free_envlst(t_env **env); +char *env_get(t_env *env, char *name); diff --git a/include/minishell.h b/include/minishell.h index 2319e8b..c84fda3 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -6,7 +6,7 @@ /* By: dkaiser args[0]); - printf("PATH=%s\n", env_get(env, "PATH")); + printf("%s\n", get_cmd_path(cmd->args[0], env)); return (0); } diff --git a/src/main.c b/src/main.c index 64bc312..e87bc99 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: chuhlig +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/22 17:14:03 by dkaiser #+# #+# */ -/* Updated: 2024/10/17 15:34:02 by dkaiser ### ########.fr */ +/* Updated: 2024/10/17 17:01:45 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,8 @@ int main(int argc, char *argv[], char *envp[]) { - t_env *env; + t_env *env; + if (!argc && !argv) return (1); if (init())