mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +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/CharacterTypes.h>
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
#include <AK/StringUtils.h>
|
#include <AK/StringUtils.h>
|
||||||
|
#include <Shell/Parser.h>
|
||||||
#include <Shell/PosixParser.h>
|
#include <Shell/PosixParser.h>
|
||||||
|
|
||||||
#define TRY_OR_THROW_PARSE_ERROR_AT(expr, position) ({ \
|
#define TRY_OR_THROW_PARSE_ERROR_AT(expr, position) ({ \
|
||||||
|
@ -23,6 +24,13 @@
|
||||||
_value_or_error.release_value(); \
|
_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()
|
static Shell::AST::Position empty_position()
|
||||||
{
|
{
|
||||||
return { 0, 0, { 0, 0 }, { 0, 0 } };
|
return { 0, 0, { 0, 0 }, { 0, 0 } };
|
||||||
|
@ -1674,9 +1682,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
||||||
'?');
|
'?');
|
||||||
break;
|
break;
|
||||||
case ResolvedParameterExpansion::Op::GetPositionalParameterListAsString:
|
case ResolvedParameterExpansion::Op::GetPositionalParameterListAsString:
|
||||||
node = make_ref_counted<AST::SyntaxError>(
|
node = strip_execute(::Shell::Parser { "${join \"${defined_value_or_default IFS ' '}\" $*}"sv }.parse());
|
||||||
token.position.value_or(empty_position()),
|
|
||||||
"$* not implemented"_string);
|
|
||||||
break;
|
break;
|
||||||
case ResolvedParameterExpansion::Op::GetShellProcessId:
|
case ResolvedParameterExpansion::Op::GetShellProcessId:
|
||||||
node = make_ref_counted<AST::SpecialVariable>(
|
node = make_ref_counted<AST::SpecialVariable>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue