Serenity Operating System
1#!/bin/Shell
2
3source $(dirname "$0")/test-commons.inc
4
5setopt --verbose
6
7rm -rf /tmp/shell-test 2> /dev/null
8mkdir -p /tmp/shell-test
9pushd /tmp/shell-test
10
11 touch a b c
12
13 # Can we do logical stuff with control structures?
14 ls && for $(seq 1) { echo yes > listing }
15 if not test "$(cat listing)" = "yes" { fail for cannot appear as second part of '&&' }
16 rm listing
17
18 # FIXME: These should work!
19
20 # for $(seq 1) { echo yes > listing } && echo HELLO!
21 # if not test "$(cat listing)" = "yes" { echo for cannot appear as first part of '&&' }
22 # rm listing
23
24 # Can we pipe things into and from control structures?
25 # ls | if true { cat > listing }
26 # if not test "$(cat listing)" = "a b c" { fail if cannot be correctly redirected to }
27 # rm listing
28
29 # ls | for $(seq 1) { cat > listing }
30 # if not test "$(cat listing)" = "a b c" { fail for cannot be correctly redirected to }
31 # rm listing
32
33 for $(seq 4) { echo $it } | cat > listing
34 if not test "$(cat listing)" = "1 2 3 4" { fail for cannot be correctly redirected from }
35 rm listing
36
37 if true { echo TRUE! } | cat > listing
38 if not test "$(cat listing)" = "TRUE!" { fail if cannot be correctly redirected from }
39 rm listing
40
41popd
42rm -rf /tmp/shell-test
43
44echo PASS