From 3398de6fa9c6805c6243a1cabe7f80c4a144e906 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 10 May 2026 14:19:29 +0100 Subject: [PATCH] ast: update redirection node to support fd-redirection with sub-expression --- bshell/ast/redirection.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bshell/ast/redirection.c b/bshell/ast/redirection.c index 88994d0..b60e1bc 100644 --- a/bshell/ast/redirection.c +++ b/bshell/ast/redirection.c @@ -27,11 +27,17 @@ static void to_string(const struct ast_node *node, fx_bstr *out) } if (redirection->n_out_is_fd) { - fx_bstr_write_fmt(out, NULL, " &%u", redirection->n_out); - } else if (redirection->n_out_is_expr) { - fx_bstr_write_fmt(out, NULL, " "); + fx_bstr_write_fmt(out, NULL, " &"); } else { - fx_bstr_write_fmt(out, NULL, " '%s'", redirection->n_out_path); + fx_bstr_write_fmt(out, NULL, " "); + } + + if (redirection->n_out_is_expr) { + fx_bstr_write_fmt(out, NULL, ""); + } else if (redirection->n_out_path) { + fx_bstr_write_fmt(out, NULL, "'%s'", redirection->n_out_path); + } else { + fx_bstr_write_fmt(out, NULL, "%u", redirection->n_out); } }