From 91bb3af5059733fe41881887648bc55e3f30dca6 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 13 Oct 2023 03:11:12 +0330 Subject: [PATCH] Shell: Implement the '$*' special variable in the POSIX parser Fixes #21421. --- Userland/Shell/PosixParser.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Shell/PosixParser.cpp b/Userland/Shell/PosixParser.cpp index 615cf3afca..9eeab54583 100644 --- a/Userland/Shell/PosixParser.cpp +++ b/Userland/Shell/PosixParser.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #define TRY_OR_THROW_PARSE_ERROR_AT(expr, position) ({ \ @@ -23,6 +24,13 @@ _value_or_error.release_value(); \ }) +static RefPtr strip_execute(RefPtr node) +{ + while (node && node->is_execute()) + node = static_ptr_cast(node)->command(); + return node; +} + static Shell::AST::Position empty_position() { return { 0, 0, { 0, 0 }, { 0, 0 } }; @@ -1674,9 +1682,7 @@ ErrorOr> Parser::parse_word() '?'); break; case ResolvedParameterExpansion::Op::GetPositionalParameterListAsString: - node = make_ref_counted( - token.position.value_or(empty_position()), - "$* not implemented"_string); + node = strip_execute(::Shell::Parser { "${join \"${defined_value_or_default IFS ' '}\" $*}"sv }.parse()); break; case ResolvedParameterExpansion::Op::GetShellProcessId: node = make_ref_counted(