File: until-p.tst

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (142 lines) | stat: -rw-r--r-- 1,964 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# until-p.tst: test of until loop for any POSIX-compliant shell

posix="true"

test_oE 'execution path of 0-round loop'
i=0
until [ $((i=i+1)) -gt 0 ];do echo $i;done
echo done $i
__IN__
done 1
__OUT__

test_oE 'execution path of 1-round loop'
i=0
until [ $((i=i+1)) -gt 1 ];do echo $i;done
echo done $i
__IN__
1
done 2
__OUT__

test_oE 'execution path of 2-round loop'
i=0
until [ $((i=i+1)) -gt 2 ];do echo $i;done
echo done $i
__IN__
1
2
done 3
__OUT__

(
setup <<\__END__
\unalias \x
x() { return $1; }
__END__

test_x -e 0 'exit status of 0-round loop'
until true;do :;done
__IN__

test_x -e 1 'exit status of 1-round loop'
i=0
until [ $((i=i+1)) -gt 1 ];do x $i;done
__IN__

test_x -e 2 'exit status of 2-round loop'
i=0
until [ $((i=i+1)) -gt 2 ];do x $i;done
__IN__

)

test_oE 'linebreak after until'
i=0
until
    
    [ $((i=i+1)) -gt 2 ];do echo $i;done
__IN__
1
2
__OUT__

test_oE 'linebreak before do'
i=0
until [ $((i=i+1)) -gt 2 ]

    do echo $i;done
__IN__
1
2
__OUT__

test_oE 'linebreak after do'
i=0
until [ $((i=i+1)) -gt 2 ];do
    
    echo $i;done
__IN__
1
2
__OUT__

test_oE 'linebreak before done'
i=0
until [ $((i=i+1)) -gt 2 ];do echo $i

    done
__IN__
1
2
__OUT__

test_oE 'command ending with asynchronous command (condition)'
until echo foo&do echo not reached;break;done;wait
__IN__
foo
__OUT__

test_oE 'command ending with asynchronous command (body)'
i=0
until [ $((i=i+1)) -gt 1 ];do echo $i&done
wait
__IN__
1
__OUT__

test_oE 'more than one inner command'
i=0
until i=$((i+1)); [ $i -gt 2 ];do echo $i;echo -;done
__IN__
1
-
2
-
__OUT__

test_oE 'nest between until and do'
i=0
until { [ $((i=i+1)) -gt 1 ]; } do echo $i;done
__IN__
1
__OUT__

test_oE 'nest between do and done'
i=0
until [ $((i=i+1)) -gt 1 ]; do { echo $i;} done
__IN__
1
__OUT__

test_oE 'redirection on until loop'
i=0
until echo -;[ $((i=i+1)) -gt 1 ];do echo $i;done >redir_out
cat redir_out
__IN__
-
1
-
__OUT__

# vim: set ft=sh ts=8 sts=4 sw=4 et: