print executable path

This commit is contained in:
whaffman 2025-02-08 19:46:45 +01:00
parent 3aa6459969
commit 2d8c58c7a9
2 changed files with 15 additions and 3 deletions

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/04 16:13:13 by whaffman #+# #+# */ /* Created: 2025/02/04 16:13:13 by whaffman #+# #+# */
/* Updated: 2025/02/05 16:28:59 by whaffman ######## odam.nl */ /* Updated: 2025/02/08 19:45:37 by willem ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,6 +19,7 @@
# include "environment.h" # include "environment.h"
# include "prompt.h" # include "prompt.h"
# include "tokenizer.h" # include "tokenizer.h"
# include "executor.h"
# include "utils.h" # include "utils.h"
# define TRUE 1 # define TRUE 1

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */ /* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */
/* Updated: 2025/02/08 14:41:19 by willem ######## odam.nl */ /* Updated: 2025/02/08 19:46:26 by willem ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -55,6 +55,8 @@ static int cmp_value(t_list *list, char *str)
void simple_builtins(t_minishell *minishell) void simple_builtins(t_minishell *minishell)
{ {
char *path;
if (cmp_value(minishell->tokens, "clear")) if (cmp_value(minishell->tokens, "clear"))
printf("\033[2J\033[1;1H"); printf("\033[2J\033[1;1H");
else if (cmp_value(minishell->tokens, "env")) else if (cmp_value(minishell->tokens, "env"))
@ -65,7 +67,16 @@ void simple_builtins(t_minishell *minishell)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
else if (cmp_value(minishell->tokens, "export")) else if (cmp_value(minishell->tokens, "export"))
{
builtin_export(minishell); builtin_export(minishell);
else
{
path = executor_absolute_path(minishell->environment, ((t_token *)minishell->tokens->content)->value);
if (path == NULL)
printf("minishell: %s: command not found\n", ((t_token *)minishell->tokens->content)->value);
else
{
printf("found excutable: %s\n", path);
free(path);
}
} }
} }