From ecf01a6b8b26f842dfff7dc84f7c3225437f60f7 Mon Sep 17 00:00:00 2001 From: Maix0 Date: Sun, 11 Aug 2024 12:53:03 +0200 Subject: [PATCH] Fixed exit builtin --- exec/src/builtins/env.c | 4 ++-- exec/src/builtins/exit.c | 4 ++-- exec/src/run_ast.c | 13 ++++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/exec/src/builtins/env.c b/exec/src/builtins/env.c index 84c3a91e..4d4bac53 100644 --- a/exec/src/builtins/env.c +++ b/exec/src/builtins/env.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */ -/* Updated: 2024/08/11 11:25:42 by maiboyer ### ########.fr */ +/* Updated: 2024/08/11 12:49:51 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ static t_error _print_env(t_usize _idx, const t_str *key, t_str *value, void *vc if (val == NULL || *val == NULL) return (NO_ERROR); // TODO: Fix this to handle the corrrect output - me_printf_fd(NULL, "%s=%s\n", *key, *val); + me_printf_fd(ctx->info->stdout, "%s=%s\n", *key, *val); return (NO_ERROR); } diff --git a/exec/src/builtins/exit.c b/exec/src/builtins/exit.c index 8f881516..186254e0 100644 --- a/exec/src/builtins/exit.c +++ b/exec/src/builtins/exit.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */ -/* Updated: 2024/08/11 11:26:03 by maiboyer ### ########.fr */ +/* Updated: 2024/08/11 12:41:07 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ t_error builtin_exit__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co if (info.args.len < 2) actual_exit_code = 0; else if (str_to_i32(info.args.buffer[1], 10, &actual_exit_code)) - return (ERROR); + return (printf("info.args.buffer[1] = %s\n", info.args.buffer[1]), ERROR); *exit_code = actual_exit_code; me_exit(actual_exit_code); return (NO_ERROR); diff --git a/exec/src/run_ast.c b/exec/src/run_ast.c index 9f2eb14e..6d4f5e25 100644 --- a/exec/src/run_ast.c +++ b/exec/src/run_ast.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */ -/* Updated: 2024/08/11 12:19:11 by maiboyer ### ########.fr */ +/* Updated: 2024/08/11 12:48:42 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -452,6 +452,14 @@ t_error _word_into_str(t_ast_node self, t_state *state, t_vec_str *append) return (NO_ERROR); } +t_error _raw_str_into_str(t_ast_node self, t_state *state, t_vec_str *append) +{ + if (self == NULL || state == NULL || append == NULL || self->kind != AST_RAW_STRING) + return (ERROR); + vec_str_push(append, str_clone(self->data.raw_string.str)); + return (NO_ERROR); +} + t_error _ast_into_str(t_ast_node self, t_state *state, t_vec_str *append) { if (self == NULL || state == NULL || append == NULL) @@ -464,6 +472,9 @@ t_error _ast_into_str(t_ast_node self, t_state *state, t_vec_str *append) return (_cmd_into_str(self, state, append)); if (self->kind == AST_WORD) return (_word_into_str(self, state, append)); + if (self->kind == AST_RAW_STRING) + return (_raw_str_into_str(self, state, append)); + printf("unknown Kind = %#04x\n", self->kind); return (ERROR); }