1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

Shell: Add support for enumerating lists in for loops

With some odd syntax to boot:
```sh
$ for index i x in $whatever {}
```
This commit is contained in:
AnotherTest 2021-03-05 18:25:09 +03:30 committed by Andreas Kling
parent a45b2ea6fb
commit 13b65b632a
8 changed files with 133 additions and 23 deletions

View file

@ -23,6 +23,19 @@ for cmd in ((test 1 = 1) (test 2 = 2)) {
$cmd || unset singlecommand_ok
}
# with index
for index i val in (0 1 2) {
if not test "$i" -eq "$val" {
unset singlecommand_ok
}
}
for index i val in (1 2 3) {
if not test "$i" -ne "$val" {
unset singlecommand_ok
}
}
# Multiple commands in block
for cmd in ((test 1 = 1) (test 2 = 2)) {
test -z "$cmd"