1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

Shell: Correctly keep track of special parameter length

We were previously treating special expansions (e.g. $#) as zero-length
expansions, which made the shell repeat them literally after expanding
them.
This commit is contained in:
Ali Mohammad Pur 2023-02-16 21:35:39 +03:30 committed by Ali Mohammad Pur
parent 6da438e992
commit a6d77162f4

View file

@ -751,7 +751,9 @@ Lexer::ReductionResult Lexer::reduce_special_parameter_expansion()
.parameter = StringBuilder {},
.range = range(-1),
};
m_state.expansions.last().get<ParameterExpansion>().parameter.append(ch);
auto& expansion = m_state.expansions.last().get<ParameterExpansion>();
expansion.parameter.append(ch);
expansion.range.length = m_state.position.end_offset - expansion.range.start - m_state.position.start_offset;
return {
.tokens = {},