aboutsummaryrefslogtreecommitdiff
path: root/testdir/T.errmsg
blob: ee2450acd1f5a9f9a850f498577816fd5b4bbd01 (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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
echo T.errmsg:  check some error messages

awk=${awk-../a.out}

ls >glop
awk=$awk awk  '
{	pat = $0
	prog = ""
	while (getline x > 0 && x != "")
		prog = prog "\n" x
	print sprintf("\n%s '"'"'%s'"'"' <glop >>devnull 2>foo",
		ENVIRON["awk"], prog)
	print sprintf("grep '"'"'%s'"'"' foo >>devnull || echo '"'"'BAD: %s'"'"' failed", pat, pat)
}
' >foo.sh <<\!!!!
illegal primary in regular expression
/(/

illegal break, continue, next or nextfile from BEGIN
BEGIN { nextfile }

illegal break, continue, next or nextfile from END
END { nextfile }

nextfile is illegal inside a function
function foo() { nextfile }

duplicate argument
function f(i,j,i) { return i }

nonterminated character class
/[[/

nonterminated character class
/[]/

nonterminated character class
/[\

nonterminated character class
BEGIN { s = "[x"; if (1 ~ s) print "foo"}

syntax error in regular expression
BEGIN { if ("x" ~ /$^/) print "ugh" }

syntax error in regular expression
/((.)/

division by zero
BEGIN { print 1/0 }

division by zero in /=
BEGIN { x = 1; print x /= 0 }

division by zero in %=
BEGIN { x = 1; print x %= 0 }

division by zero in mod
BEGIN { print 1%0 }

can.t read value.* array name.
BEGIN { x[1] = 0; split("a b c", y, x) }

can.t read value.* function
function f(){}; {split($0, x, f)}

can.t assign.* a function
function f(){}; {f = split($0, x)}

can.t assign to x; it.s an array name.
{x = split($0, x)}

is a function, not an array
function f(){}; {split($0, f)}

function f called with 1 args, uses only 0
BEGIN { f(f) }
function f() { print "x" }

can.t use function f as argument in f
BEGIN { f(f) }
function f() { print "x" }

x is an array, not a function
{ split($0, x) }; function x() {}

illegal nested function
function x() { function g() {} }

return not in function
{ return }

break illegal outside
{ break }

continue illegal outside
{ continue }

non-terminated string
{ print "abc
}

illegal field $(foo)
BEGIN { print $"foo" }

next is illegal inside a function
BEGIN { f() }
function f() { next }

not enough args in printf(%s)
BEGIN { printf("%s") }

weird printf conversion
BEGIN { printf("%z", "foo")}

function f has .* arguments, limit .*
function f(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,
	c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,
	e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) {}
BEGIN { f(123) }

bailing out
])}

bailing out
{ print }}

bailing out
{ print }}}

bailing out
]

bailing out
[

bailing out
a & b

extra )
{ x = 1) }

illegal statement
{ print ))}

illegal statement
{{ print }

illegal statement
{{{ print }

illegal .*next.* from BEGIN
BEGIN { next }

illegal .*next.* from END
END {	next; print NR }

can.t open file ./nonexistentdir/foo
BEGIN { print "abc" >"./nonexistentdir/foo" }

you can.t define function f more than once
function f() { print 1 }
function f() { print 2 }

function mp called with 1 args, uses only 0
function mp(){ cnt++;}
BEGIN {	mp(xx) }

index.*doesn.t permit regular expressions
BEGIN { index("abc", /a/) }

log argument out of domain
BEGIN { print log(-1) }

exp result out of range
BEGIN {print exp(1000)}

null file name in print or getline
BEGIN { print >foo }

function has too many arguments
BEGIN { length("abc", "def") }

calling undefined function foo
BEGIN { foo() }

this should print a BAD message
BEGIN { print }
!!!!


echo '	running tests in foo.sh'
sh foo.sh

test -r core && echo BAD: someone dropped core 1>&2

echo xxx >foo0
$awk '{print x}' x='a
b' foo0 >foo1 2>foo2
grep 'newline in string' foo2 >/dev/null || echo 'BAD: T.errmsg newline in string'

$awk -safe 'BEGIN{"date" | getline}' >foo 2>foo2
grep 'cmd | getline is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg cmd|getline unsafe'

$awk -safe 'BEGIN{print >"foo"}' >foo 2>foo2
grep 'print > is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg print > unsafe'

$awk -safe 'BEGIN{print >> "foo"}' >foo 2>foo2
grep 'print >> is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg print >> unsafe'

$awk -safe 'BEGIN{print | "foo"}' >foo 2>foo2
grep 'print | is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg print | unsafe'

$awk -safe 'BEGIN {system("date")}' >foo 2>foo2
grep 'system is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg system unsafe'