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); } }