]> git.dkaiser.de - 42/minishell.git/commitdiff
Add path handling
authorDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Thu, 17 Oct 2024 15:19:48 +0000 (17:19 +0200)
committerDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Thu, 17 Oct 2024 15:19:48 +0000 (17:19 +0200)
Makefile
include/env.h
include/minishell.h
src/interpreter.c
src/main.c

index 283db1a38f9886791e017e3675de1d65eb386fe6..3ae13596e90cf5ecd5fae0f20b82136d0605e9ab 100644 (file)
--- 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))
index ee011811befd159bcdae65977bf0d85daa591d89..f22ebddeb4b7d931670bfe4047ac217c090f6272 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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);
index 2319e8b90282715247ac57708a3ef6ae92d0d3f1..c84fda36cbcc3d0cf44f60c3e070a735e9a12083 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/06/22 17:14:49 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/10/17 15:25:58 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/10/17 17:09:25 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -37,5 +37,6 @@ t_redirection *collect_redirs(t_token **tokens);
 
 void                   print_ast(t_node *ast);
 
-int    eval(t_node *node, t_env *env);
+int                            eval(t_node *node, t_env *env);
+char                   *get_cmd_path(char *cmd, t_env *env);
 #endif
index abaeb474e157cf9b472399a073aced9563e2af2f..0fa7ac1184b4586c51f723732eb72fa817fc5f01 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/08/05 13:15:24 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/10/17 16:01:23 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/10/17 17:05:51 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -38,7 +38,6 @@ static int    eval_pipe(t_pipe *pipe, t_env *env)
 
 static int     eval_cmd(t_cmd *cmd, t_env *env)
 {
-       printf("%s\n", cmd->args[0]);
-       printf("PATH=%s\n", env_get(env, "PATH"));
+       printf("%s\n", get_cmd_path(cmd->args[0], env));
        return (0);
 }
index 64bc31262682c0446d6910cd8638a184d3a6336f..e87bc99ac4fe73a2ad38a7ec79c1200098ccff64 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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())