diff options
| author | Dominik Kaiser | 2025-01-14 18:20:33 +0100 |
|---|---|---|
| committer | Dominik Kaiser | 2025-01-14 18:20:33 +0100 |
| commit | 3e692dac63577011bd5862a66767ef412183f26b (patch) | |
| tree | c62096c34058d794311ac975c6611aad20f2e1a0 /src/builtins_part_one.c | |
| parent | 8c37f835ba29bcecc1d779edb396d97b18667026 (diff) | |
| download | minishell-3e692dac63577011bd5862a66767ef412183f26b.tar.gz minishell-3e692dac63577011bd5862a66767ef412183f26b.zip | |
Some changes
Diffstat (limited to 'src/builtins_part_one.c')
| -rw-r--r-- | src/builtins_part_one.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/builtins_part_one.c b/src/builtins_part_one.c index d64bb54..b6e5261 100644 --- a/src/builtins_part_one.c +++ b/src/builtins_part_one.c @@ -6,11 +6,12 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/09 17:01:16 by chuhlig #+# #+# */ -/* Updated: 2025/01/10 14:36:55 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 15:20:42 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "env.h" +#include <stdio.h> int echo(char **av) { @@ -22,7 +23,7 @@ int echo(char **av) if (av[1] == NULL || av[1][0] == '\0') { write(1, "\n", 1); - return (1); + return (0); } if (ft_strncmp(av[1], "-n", 3) == 0) { @@ -59,6 +60,11 @@ int ft_env(t_env *env) { while (env != NULL) { + if (strchr(env->name, '?')) + { + env = env->next; + continue; + } printf("%s", env->name); printf("=%s\n", env->value); env = env->next; @@ -89,6 +95,8 @@ int unset(char **av, t_env **env) i = 0; while (av[++i]) { + if (ft_strchr(av[i], '?')) + return (1); current = *env; prev = NULL; while (current) @@ -145,6 +153,8 @@ int export(char **av, t_env **env) { tmp = ft_strchr(av[i], '='); *tmp = '\0'; + if (ft_strchr(av[i], '?')) + return (1); current = check_existing(*env, av[i]); if (current) free(current->value); @@ -158,4 +168,20 @@ int export(char **av, t_env **env) } } return (0); -}
\ No newline at end of file +} + +void set_return_code(int return_code, t_env **env) +{ + t_env *cur; + + cur = check_existing(*env, "?"); + if (cur) + free(cur->value); + else + { + cur = env_new(ft_strdup("?")); + cur->next = *env; + *env = cur; + } + cur->value = ft_itoa(return_code); +} |
