mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
Shell: Implement the '$*' special variable in the POSIX parser
Fixes #21421.
This commit is contained in:
parent
5cb994d4dd
commit
91bb3af505
1 changed files with 9 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <Shell/Parser.h>
|
||||
#include <Shell/PosixParser.h>
|
||||
|
||||
#define TRY_OR_THROW_PARSE_ERROR_AT(expr, position) ({ \
|
||||
|
@ -23,6 +24,13 @@
|
|||
_value_or_error.release_value(); \
|
||||
})
|
||||
|
||||
static RefPtr<Shell::AST::Node> strip_execute(RefPtr<Shell::AST::Node> node)
|
||||
{
|
||||
while (node && node->is_execute())
|
||||
node = static_ptr_cast<Shell::AST::Execute>(node)->command();
|
||||
return node;
|
||||
}
|
||||
|
||||
static Shell::AST::Position empty_position()
|
||||
{
|
||||
return { 0, 0, { 0, 0 }, { 0, 0 } };
|
||||
|
@ -1674,9 +1682,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
'?');
|
||||
break;
|
||||
case ResolvedParameterExpansion::Op::GetPositionalParameterListAsString:
|
||||
node = make_ref_counted<AST::SyntaxError>(
|
||||
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<AST::SpecialVariable>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue