diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/builtins_part_one.c | 6 | ||||
| -rw-r--r-- | src/builtins_part_two.c | 7 | ||||
| -rw-r--r-- | src/env_to_strlst.c | 6 | ||||
| -rw-r--r-- | src/execute_cmd.c | 4 | ||||
| -rw-r--r-- | src/interpreter.c | 4 | ||||
| -rw-r--r-- | src/main.c | 5 |
6 files changed, 19 insertions, 13 deletions
diff --git a/src/builtins_part_one.c b/src/builtins_part_one.c index 9f50157..f3bcfc0 100644 --- a/src/builtins_part_one.c +++ b/src/builtins_part_one.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/09 17:01:16 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 16:51:05 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 19:51:59 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -129,13 +129,15 @@ int export(char **av, t_env **env) } current->value = ft_strdup(tmp + 1); } + else + return (1); } return (0); } void set_return_code(int return_code, t_env **env) { - t_env *cur; + t_env *cur; cur = check_existing(*env, "?"); if (cur) diff --git a/src/builtins_part_two.c b/src/builtins_part_two.c index 5af6c68..05d6943 100644 --- a/src/builtins_part_two.c +++ b/src/builtins_part_two.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/25 20:52:16 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 14:26:39 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 19:31:17 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -101,6 +101,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; diff --git a/src/env_to_strlst.c b/src/env_to_strlst.c index 40aaf9d..a1ab7cc 100644 --- a/src/env_to_strlst.c +++ b/src/env_to_strlst.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:22:28 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 14:10:49 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 19:34:10 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ char **env_to_strlst(t_env *env) if (ft_strchr(cur->name, '?')) { cur = cur->next; - continue; + continue ; } size++; cur = cur->next; @@ -42,7 +42,7 @@ char **env_to_strlst(t_env *env) while (i < size) { if (ft_strchr(cur->name, '?')) - cur = cur->next; + cur = cur->next; result[i] = get_var_assign(cur); cur = cur->next; i++; diff --git a/src/execute_cmd.c b/src/execute_cmd.c index b9faf71..525f333 100644 --- a/src/execute_cmd.c +++ b/src/execute_cmd.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:21:35 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 16:56:24 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 19:55:18 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -85,7 +85,7 @@ int execute_cmd(t_cmd *cmd, t_env **env) cmd_path = get_cmd_path(cmd->args[0], *env); if (!cmd_path) { - printf("command not found\n"); + perror("command not found"); exit(EXIT_FAILURE); } execve(cmd_path, cmd->args, env_to_strlst(*env)); diff --git a/src/interpreter.c b/src/interpreter.c index af1eb82..a1d3823 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:15:49 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 16:59:45 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 19:52:27 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ int handle_redirections(t_redirection *redirs) fd = open(redirs[0].specifier, O_RDONLY); if (fd < 0) { - perror(redirs[0].specifier); + perror("open"); return (-1); } dup2(fd, STDIN_FILENO); @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/22 17:14:03 by dkaiser #+# #+# */ -/* Updated: 2025/01/14 15:29:20 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 18:41:15 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,8 +24,7 @@ int main(int argc, char *argv[], char *envp[]) if (init()) return (1); getenvlst(&env, envp); - - set_return_code(0, &env); + set_return_code(0, &env); repl("Minishell $ ", &env, &promptflag); free_envlst(&env); return (0); |
