summaryrefslogtreecommitdiff
path: root/Userland/Shell/Tests
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-03-05 18:25:09 +0330
committerAndreas Kling <kling@serenityos.org>2021-03-07 10:59:51 +0100
commit13b65b632af48db0bd84d49799dcf22b411a6e24 (patch)
tree92cb67027f2e38eca70e6f24a31533d881de3beb /Userland/Shell/Tests
parenta45b2ea6fb1917de9c2833764f3acf0cdf4e7eab (diff)
downloadserenity-13b65b632af48db0bd84d49799dcf22b411a6e24.zip
Shell: Add support for enumerating lists in for loops
With some odd syntax to boot: ```sh $ for index i x in $whatever {} ```
Diffstat (limited to 'Userland/Shell/Tests')
-rw-r--r--Userland/Shell/Tests/loop.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Shell/Tests/loop.sh b/Userland/Shell/Tests/loop.sh
index 6d81ebf7ef..e040280ceb 100644
--- a/Userland/Shell/Tests/loop.sh
+++ b/Userland/Shell/Tests/loop.sh
@@ -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"