1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:25:07 +00:00

Shell: Fix wrong step value for brace ranges

This fixes numeric ranges like {1..10}.
This commit is contained in:
AnotherTest 2020-12-29 17:28:46 +03:30 committed by Andreas Kling
parent 5e5eb615ec
commit 66b26fc1c2

View file

@ -1978,7 +1978,7 @@ RefPtr<Value> Range::run(RefPtr<Shell> shell)
if (start_int.has_value() && end_int.has_value()) {
auto start = start_int.value();
auto end = end_int.value();
auto step = start > end ? 1 : -1;
auto step = start > end ? -1 : 1;
for (int value = start; value != end; value += step)
values.append(create<StringValue>(String::number(value)));
// Append the range end too, most shells treat this as inclusive.