blob: 178e358b15f31a9fa82ddc36f51d4a51b3755b55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/sh
source $(dirname "$0")/test-commons.inc
setopt --verbose
rm -rf shell-test
mkdir shell-test
cd shell-test
# Simple sequence (grouping)
{ echo test > testfile }
if not test "$(cat testfile)" = "test" {
fail cannot write to file in subshell
}
# Simple sequence - many commands
{ echo test1 > testfile; echo test2 > testfile }
if not test "$(cat testfile)" = "test2" {
fail cannot write to file in subshell 2
}
# Does it exit with the last exit code?
{ test -z "a" }
exitcode=$?
if not test "$exitcode" -eq 1 {
fail exits with $exitcode when it should exit with 1
}
{ test -z "a" || echo test }
exitcode=$?
if not test "$exitcode" -eq 0 {
fail exits with $exitcode when it should exit with 0
}
cd ..
rm -rf shell-test
echo PASS
|